[master] c395b65 Add even more arguments to the VCL method functions
Poul-Henning Kamp
phk at varnish-cache.org
Mon Apr 22 11:17:18 CEST 2013
commit c395b650bc838be612d5300c67e92b1f7a0a28f9
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Apr 22 09:17:06 2013 +0000
Add even more arguments to the VCL method functions
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 5e80247..a284289 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -1019,7 +1019,8 @@ const char *VCL_Return_Name(unsigned);
const char *VCL_Method_Name(unsigned);
#define VCL_MET_MAC(l,u,b) \
- void VCL_##l##_method(struct worker *, struct req *, struct ws *);
+ void VCL_##l##_method(struct VCL_conf *, struct worker *, struct req *, \
+ struct busyobj *bo, struct ws *);
#include "tbl/vcl_returns.h"
#undef VCL_MET_MAC
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 240d166..3b06a8d 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -158,7 +158,7 @@ cnt_prepresp(struct worker *wrk, struct req *req)
HTTP_Setup(req->resp, req->ws, req->vsl, HTTP_Resp);
RES_BuildHttp(req);
- VCL_deliver_method(wrk, req, req->http->ws);
+ VCL_deliver_method(req->vcl, wrk, req, NULL, req->http->ws);
switch (wrk->handling) {
case VCL_RET_DELIVER:
break;
@@ -308,7 +308,7 @@ cnt_error(struct worker *wrk, struct req *req)
http_PutResponse(h, req->err_reason);
else
http_PutResponse(h, http_StatusMessage(req->err_code));
- VCL_error_method(wrk, req, req->http->ws);
+ VCL_error_method(req->vcl, wrk, req, NULL, req->http->ws);
if (wrk->handling == VCL_RET_RESTART &&
req->restarts < cache_param->max_restarts) {
@@ -416,7 +416,8 @@ cnt_fetch(struct worker *wrk, struct req *req)
AZ(bo->do_esi);
AZ(bo->do_pass);
- VCL_backend_response_method(wrk, req, req->http->ws);
+ VCL_backend_response_method(req->vcl, wrk, req, NULL,
+ req->http->ws);
if (bo->do_pass)
req->objcore->flags |= OC_F_PASS;
@@ -845,7 +846,7 @@ VSLb(req->vsl, SLT_Debug, "XXXX HIT\n");
AZ(req->objcore);
AZ(req->busyobj);
- VCL_lookup_method(wrk, req, req->http->ws);
+ VCL_lookup_method(req->vcl, wrk, req, NULL, req->http->ws);
if ((req->obj->objcore->flags & OC_F_PASS) &&
wrk->handling == VCL_RET_DELIVER) {
@@ -923,8 +924,8 @@ cnt_miss(struct worker *wrk, struct req *req)
http_SetHeader(bo->bereq, "Accept-Encoding: gzip");
}
- VCL_backend_fetch_method(wrk, req, req->http->ws);
- VCL_miss_method(wrk, req, req->http->ws);
+ VCL_backend_fetch_method(req->vcl, wrk, req, NULL, req->http->ws);
+ VCL_miss_method(req->vcl, wrk, req, NULL, req->http->ws);
if (wrk->handling == VCL_RET_FETCH) {
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
@@ -988,8 +989,8 @@ cnt_pass(struct worker *wrk, struct req *req)
HTTP_Setup(bo->bereq, bo->ws, bo->vsl, HTTP_Bereq);
http_FilterReq(req, HTTPH_R_PASS);
- VCL_backend_fetch_method(wrk, req, req->http->ws);
- VCL_pass_method(wrk, req, req->http->ws);
+ VCL_backend_fetch_method(req->vcl, wrk, req, NULL, req->http->ws);
+ VCL_pass_method(req->vcl, wrk, req, NULL, req->http->ws);
if (wrk->handling == VCL_RET_ERROR) {
http_Teardown(bo->bereq);
@@ -1047,7 +1048,7 @@ cnt_pipe(struct worker *wrk, struct req *req)
HTTP_Setup(bo->bereq, bo->ws, bo->vsl, HTTP_Bereq);
http_FilterReq(req, 0);
- VCL_pipe_method(wrk, req, req->http->ws);
+ VCL_pipe_method(req->vcl, wrk, req, NULL, req->http->ws);
if (wrk->handling == VCL_RET_ERROR)
INCOMPL();
@@ -1153,7 +1154,7 @@ cnt_recv(struct worker *wrk, struct req *req)
http_CollectHdr(req->http, H_Cache_Control);
- VCL_recv_method(wrk, req, req->http->ws);
+ VCL_recv_method(req->vcl, wrk, req, NULL, req->http->ws);
recv_handling = wrk->handling;
if (cache_param->http_gzip_support &&
@@ -1169,7 +1170,7 @@ cnt_recv(struct worker *wrk, struct req *req)
req->sha256ctx = &sha256ctx; /* so HSH_AddString() can find it */
SHA256_Init(req->sha256ctx);
- VCL_hash_method(wrk, req, req->http->ws);
+ VCL_hash_method(req->vcl, wrk, req, NULL, req->http->ws);
assert(wrk->handling == VCL_RET_HASH);
SHA256_Final(req->digest, req->sha256ctx);
req->sha256ctx = NULL;
diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c
index 6cddd28..7c70c11 100644
--- a/bin/varnishd/cache/cache_vcl.c
+++ b/bin/varnishd/cache/cache_vcl.c
@@ -358,33 +358,42 @@ ccf_config_use(struct cli *cli, const char * const *av, void *priv)
/*--------------------------------------------------------------------*/
static void
-vcl_call_method(struct worker *wrk, struct req *req, struct ws *ws,
- unsigned method, vcl_func_f *func)
+vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo,
+ struct ws *ws, unsigned method, vcl_func_f *func)
{
char *aws;
+ struct vsl_log *vsl;
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
- CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
- CHECK_OBJ_NOTNULL(req->sp, SESS_MAGIC);
- AN(req->sp);
+ if (req != NULL) {
+ AZ(bo);
+ CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+ CHECK_OBJ_NOTNULL(req->sp, SESS_MAGIC);
+ vsl = req->vsl;
+ } else {
+ AZ(req);
+ CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+ vsl = bo->vsl;
+ }
aws = WS_Snapshot(wrk->aws);
wrk->handling = 0;
wrk->cur_method = method;
- VSLb(req->vsl, SLT_VCL_call, "%s", VCL_Method_Name(method));
+ VSLb(vsl, SLT_VCL_call, "%s", VCL_Method_Name(method));
(void)func(wrk, req, NULL, ws);
- VSLb(req->vsl, SLT_VCL_return, "%s", VCL_Return_Name(wrk->handling));
+ VSLb(vsl, SLT_VCL_return, "%s", VCL_Return_Name(wrk->handling));
wrk->cur_method = 0;
WS_Reset(wrk->aws, aws);
}
#define VCL_MET_MAC(func, upper, bitmap) \
void \
-VCL_##func##_method(struct worker *wrk, struct req *req, struct ws *ws) \
+VCL_##func##_method(struct VCL_conf *vcl, struct worker *wrk, \
+ struct req *req, struct busyobj *bo, struct ws *ws) \
{ \
\
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); \
- vcl_call_method(wrk, req, ws, VCL_MET_ ## upper, \
- req->vcl->func##_func); \
+ vcl_call_method(wrk, req, bo, ws, VCL_MET_ ## upper, \
+ vcl->func##_func); \
assert((1U << wrk->handling) & bitmap); \
assert(!((1U << wrk->handling) & ~bitmap)); \
}
More information about the varnish-commit
mailing list