[master] 69f498d Pass the designated workspace to the VCL methods.
Poul-Henning Kamp
phk at varnish-cache.org
Tue Apr 16 11:12:14 CEST 2013
commit 69f498d49e0e8d2a11d13057dc34d6ca394618f9
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Apr 16 09:11:52 2013 +0000
Pass the designated workspace to the VCL methods.
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 1b2aaed..051defb 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -1016,7 +1016,8 @@ void VCL_Rel(struct VCL_conf **vcc);
void VCL_Poll(void);
const char *VCL_Return_Name(unsigned method);
-#define VCL_MET_MAC(l,u,b) void VCL_##l##_method(struct worker *, struct req *);
+#define VCL_MET_MAC(l,u,b) \
+ void VCL_##l##_method(struct worker *, struct req *, 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 49d5fa1..2df6dd8 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);
+ VCL_deliver_method(wrk, req, req->http->ws);
switch (req->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);
+ VCL_error_method(wrk, req, req->http->ws);
if (req->handling == VCL_RET_RESTART &&
req->restarts < cache_param->max_restarts) {
@@ -416,7 +416,7 @@ cnt_fetch(struct worker *wrk, struct req *req)
AZ(bo->do_esi);
AZ(bo->do_pass);
- VCL_response_method(wrk, req);
+ VCL_response_method(wrk, req, req->http->ws);
if (bo->do_pass)
req->objcore->flags |= OC_F_PASS;
@@ -845,7 +845,7 @@ VSLb(req->vsl, SLT_Debug, "XXXX HIT\n");
AZ(req->objcore);
AZ(req->busyobj);
- VCL_lookup_method(wrk, req);
+ VCL_lookup_method(wrk, req, req->http->ws);
if ((req->obj->objcore->flags & OC_F_PASS) &&
req->handling == VCL_RET_DELIVER) {
@@ -923,8 +923,8 @@ cnt_miss(struct worker *wrk, struct req *req)
http_SetHeader(bo->bereq, "Accept-Encoding: gzip");
}
- VCL_fetch_method(wrk, req);
- VCL_miss_method(wrk, req);
+ VCL_fetch_method(wrk, req, req->http->ws);
+ VCL_miss_method(wrk, req, req->http->ws);
if (req->handling == VCL_RET_FETCH) {
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
@@ -988,8 +988,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_fetch_method(wrk, req);
- VCL_pass_method(wrk, req);
+ VCL_fetch_method(wrk, req, req->http->ws);
+ VCL_pass_method(wrk, req, req->http->ws);
if (req->handling == VCL_RET_ERROR) {
http_Teardown(bo->bereq);
@@ -1047,7 +1047,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);
+ VCL_pipe_method(wrk, req, req->http->ws);
if (req->handling == VCL_RET_ERROR)
INCOMPL();
@@ -1153,7 +1153,7 @@ cnt_recv(struct worker *wrk, struct req *req)
http_CollectHdr(req->http, H_Cache_Control);
- VCL_recv_method(wrk, req);
+ VCL_recv_method(wrk, req, req->http->ws);
recv_handling = req->handling;
if (cache_param->http_gzip_support &&
@@ -1169,7 +1169,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);
+ VCL_hash_method(wrk, req, req->http->ws);
assert(req->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 8971550..a86bff7 100644
--- a/bin/varnishd/cache/cache_vcl.c
+++ b/bin/varnishd/cache/cache_vcl.c
@@ -191,7 +191,7 @@ VCL_Load(const char *fn, const char *name, struct cli *cli)
REPLACE(vcl->name, name);
VCLI_Out(cli, "Loaded \"%s\" as \"%s\"", fn , name);
VTAILQ_INSERT_TAIL(&vcl_head, vcl, list);
- (void)vcl->conf->init_func(NULL, NULL);
+ (void)vcl->conf->init_func(NULL, NULL, NULL);
Lck_Lock(&vcl_mtx);
if (vcl_active == NULL)
vcl_active = vcl;
@@ -215,7 +215,7 @@ VCL_Nuke(struct vcls *vcl)
assert(vcl->conf->discard);
assert(vcl->conf->busy == 0);
VTAILQ_REMOVE(&vcl_head, vcl, list);
- (void)vcl->conf->fini_func(NULL, NULL);
+ (void)vcl->conf->fini_func(NULL, NULL, NULL);
vcl->conf->fini_vcl(NULL);
free(vcl->name);
(void)dlclose(vcl->dlh);
@@ -336,7 +336,7 @@ ccf_config_use(struct cli *cli, const char * const *av, void *priv)
#define VCL_MET_MAC(func, upper, bitmap) \
void \
-VCL_##func##_method(struct worker *wrk, struct req *req) \
+VCL_##func##_method(struct worker *wrk, struct req *req, struct ws *ws) \
{ \
char *aws; \
\
@@ -347,7 +347,7 @@ VCL_##func##_method(struct worker *wrk, struct req *req) \
req->handling = 0; \
req->cur_method = VCL_MET_ ## upper; \
VSLb(req->vsl, SLT_VCL_call, "%s", #func); \
- (void)req->vcl->func##_func(wrk, req); \
+ (void)req->vcl->func##_func(wrk, req, ws); \
VSLb(req->vsl, SLT_VCL_return, "%s", \
VCL_Return_Name(req->handling)); \
req->cur_method = 0; \
diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py
index 3bdbed6..67486f1 100755
--- a/lib/libvcl/generate.py
+++ b/lib/libvcl/generate.py
@@ -745,12 +745,13 @@ file_header(fo)
fo.write("""
struct sess;
struct req;
+struct ws;
struct cli;
struct worker;
typedef int vcl_init_f(struct cli *);
typedef void vcl_fini_f(struct cli *);
-typedef int vcl_func_f(struct worker *wrk, struct req *req);
+typedef int vcl_func_f(struct worker *, struct req *, struct ws *);
""")
diff --git a/lib/libvcl/vcc_compile.c b/lib/libvcl/vcc_compile.c
index 3aa1916..99c5878 100644
--- a/lib/libvcl/vcc_compile.c
+++ b/lib/libvcl/vcc_compile.c
@@ -693,7 +693,8 @@ vcc_CompileSource(const struct vcc *tl0, struct vsb *sb, struct source *sp)
for (i = 0; i < VCL_MET_MAX; i++) {
Fc(tl, 1, "\nstatic int __match_proto__(vcl_func_f)\n");
Fc(tl, 1,
- "VGC_function_%s(struct worker *wrk, struct req *req)\n",
+ "VGC_function_%s(struct worker *wrk,"
+ " struct req *req, struct ws *ws)\n",
method_tab[i].name);
AZ(VSB_finish(tl->fm[i]));
Fc(tl, 1, "{\n");
More information about the varnish-commit
mailing list