Commit 9b091b5e authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

In the future we will need VCL also when we don't have a "struct req"

at hand, most notably in the backend functions.

Pass also a struct worker pointer to all VCL methods.
parent 12f5a29c
...@@ -1016,7 +1016,7 @@ void VCL_Rel(struct VCL_conf **vcc); ...@@ -1016,7 +1016,7 @@ void VCL_Rel(struct VCL_conf **vcc);
void VCL_Poll(void); void VCL_Poll(void);
const char *VCL_Return_Name(unsigned method); const char *VCL_Return_Name(unsigned method);
#define VCL_MET_MAC(l,u,b) void VCL_##l##_method(struct req *); #define VCL_MET_MAC(l,u,b) void VCL_##l##_method(struct worker *, struct req *);
#include "tbl/vcl_returns.h" #include "tbl/vcl_returns.h"
#undef VCL_MET_MAC #undef VCL_MET_MAC
......
...@@ -158,7 +158,7 @@ cnt_prepresp(struct worker *wrk, struct req *req) ...@@ -158,7 +158,7 @@ cnt_prepresp(struct worker *wrk, struct req *req)
HTTP_Setup(req->resp, req->ws, req->vsl, HTTP_Resp); HTTP_Setup(req->resp, req->ws, req->vsl, HTTP_Resp);
RES_BuildHttp(req); RES_BuildHttp(req);
VCL_deliver_method(req); VCL_deliver_method(wrk, req);
switch (req->handling) { switch (req->handling) {
case VCL_RET_DELIVER: case VCL_RET_DELIVER:
break; break;
...@@ -308,7 +308,7 @@ cnt_error(struct worker *wrk, struct req *req) ...@@ -308,7 +308,7 @@ cnt_error(struct worker *wrk, struct req *req)
http_PutResponse(h, req->err_reason); http_PutResponse(h, req->err_reason);
else else
http_PutResponse(h, http_StatusMessage(req->err_code)); http_PutResponse(h, http_StatusMessage(req->err_code));
VCL_error_method(req); VCL_error_method(wrk, req);
if (req->handling == VCL_RET_RESTART && if (req->handling == VCL_RET_RESTART &&
req->restarts < cache_param->max_restarts) { req->restarts < cache_param->max_restarts) {
...@@ -416,7 +416,7 @@ cnt_fetch(struct worker *wrk, struct req *req) ...@@ -416,7 +416,7 @@ cnt_fetch(struct worker *wrk, struct req *req)
AZ(bo->do_esi); AZ(bo->do_esi);
AZ(bo->do_pass); AZ(bo->do_pass);
VCL_response_method(req); VCL_response_method(wrk, req);
if (bo->do_pass) if (bo->do_pass)
req->objcore->flags |= OC_F_PASS; req->objcore->flags |= OC_F_PASS;
...@@ -845,7 +845,7 @@ VSLb(req->vsl, SLT_Debug, "XXXX HIT\n"); ...@@ -845,7 +845,7 @@ VSLb(req->vsl, SLT_Debug, "XXXX HIT\n");
AZ(req->objcore); AZ(req->objcore);
AZ(req->busyobj); AZ(req->busyobj);
VCL_lookup_method(req); VCL_lookup_method(wrk, req);
if ((req->obj->objcore->flags & OC_F_PASS) && if ((req->obj->objcore->flags & OC_F_PASS) &&
req->handling == VCL_RET_DELIVER) { req->handling == VCL_RET_DELIVER) {
...@@ -923,8 +923,8 @@ cnt_miss(struct worker *wrk, struct req *req) ...@@ -923,8 +923,8 @@ cnt_miss(struct worker *wrk, struct req *req)
http_SetHeader(bo->bereq, "Accept-Encoding: gzip"); http_SetHeader(bo->bereq, "Accept-Encoding: gzip");
} }
VCL_fetch_method(req); VCL_fetch_method(wrk, req);
VCL_miss_method(req); VCL_miss_method(wrk, req);
if (req->handling == VCL_RET_FETCH) { if (req->handling == VCL_RET_FETCH) {
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
...@@ -988,8 +988,8 @@ cnt_pass(struct worker *wrk, struct req *req) ...@@ -988,8 +988,8 @@ cnt_pass(struct worker *wrk, struct req *req)
HTTP_Setup(bo->bereq, bo->ws, bo->vsl, HTTP_Bereq); HTTP_Setup(bo->bereq, bo->ws, bo->vsl, HTTP_Bereq);
http_FilterReq(req, HTTPH_R_PASS); http_FilterReq(req, HTTPH_R_PASS);
VCL_fetch_method(req); VCL_fetch_method(wrk, req);
VCL_pass_method(req); VCL_pass_method(wrk, req);
if (req->handling == VCL_RET_ERROR) { if (req->handling == VCL_RET_ERROR) {
http_Teardown(bo->bereq); http_Teardown(bo->bereq);
...@@ -1047,7 +1047,7 @@ cnt_pipe(struct worker *wrk, struct req *req) ...@@ -1047,7 +1047,7 @@ cnt_pipe(struct worker *wrk, struct req *req)
HTTP_Setup(bo->bereq, bo->ws, bo->vsl, HTTP_Bereq); HTTP_Setup(bo->bereq, bo->ws, bo->vsl, HTTP_Bereq);
http_FilterReq(req, 0); http_FilterReq(req, 0);
VCL_pipe_method(req); VCL_pipe_method(wrk, req);
if (req->handling == VCL_RET_ERROR) if (req->handling == VCL_RET_ERROR)
INCOMPL(); INCOMPL();
...@@ -1119,7 +1119,7 @@ DOT hash -> lookup [label="hash",style=bold,color=green] ...@@ -1119,7 +1119,7 @@ DOT hash -> lookup [label="hash",style=bold,color=green]
*/ */
static enum req_fsm_nxt static enum req_fsm_nxt
cnt_recv(const struct worker *wrk, struct req *req) cnt_recv(struct worker *wrk, struct req *req)
{ {
unsigned recv_handling; unsigned recv_handling;
struct SHA256Context sha256ctx; struct SHA256Context sha256ctx;
...@@ -1153,7 +1153,7 @@ cnt_recv(const struct worker *wrk, struct req *req) ...@@ -1153,7 +1153,7 @@ cnt_recv(const struct worker *wrk, struct req *req)
http_CollectHdr(req->http, H_Cache_Control); http_CollectHdr(req->http, H_Cache_Control);
VCL_recv_method(req); VCL_recv_method(wrk, req);
recv_handling = req->handling; recv_handling = req->handling;
if (cache_param->http_gzip_support && if (cache_param->http_gzip_support &&
...@@ -1169,7 +1169,7 @@ cnt_recv(const struct worker *wrk, struct req *req) ...@@ -1169,7 +1169,7 @@ cnt_recv(const struct worker *wrk, struct req *req)
req->sha256ctx = &sha256ctx; /* so HSH_AddString() can find it */ req->sha256ctx = &sha256ctx; /* so HSH_AddString() can find it */
SHA256_Init(req->sha256ctx); SHA256_Init(req->sha256ctx);
VCL_hash_method(req); VCL_hash_method(wrk, req);
assert(req->handling == VCL_RET_HASH); assert(req->handling == VCL_RET_HASH);
SHA256_Final(req->digest, req->sha256ctx); SHA256_Final(req->digest, req->sha256ctx);
req->sha256ctx = NULL; req->sha256ctx = NULL;
......
...@@ -191,7 +191,7 @@ VCL_Load(const char *fn, const char *name, struct cli *cli) ...@@ -191,7 +191,7 @@ VCL_Load(const char *fn, const char *name, struct cli *cli)
REPLACE(vcl->name, name); REPLACE(vcl->name, name);
VCLI_Out(cli, "Loaded \"%s\" as \"%s\"", fn , name); VCLI_Out(cli, "Loaded \"%s\" as \"%s\"", fn , name);
VTAILQ_INSERT_TAIL(&vcl_head, vcl, list); VTAILQ_INSERT_TAIL(&vcl_head, vcl, list);
(void)vcl->conf->init_func(NULL); (void)vcl->conf->init_func(NULL, NULL);
Lck_Lock(&vcl_mtx); Lck_Lock(&vcl_mtx);
if (vcl_active == NULL) if (vcl_active == NULL)
vcl_active = vcl; vcl_active = vcl;
...@@ -215,7 +215,7 @@ VCL_Nuke(struct vcls *vcl) ...@@ -215,7 +215,7 @@ VCL_Nuke(struct vcls *vcl)
assert(vcl->conf->discard); assert(vcl->conf->discard);
assert(vcl->conf->busy == 0); assert(vcl->conf->busy == 0);
VTAILQ_REMOVE(&vcl_head, vcl, list); VTAILQ_REMOVE(&vcl_head, vcl, list);
(void)vcl->conf->fini_func(NULL); (void)vcl->conf->fini_func(NULL, NULL);
vcl->conf->fini_vcl(NULL); vcl->conf->fini_vcl(NULL);
free(vcl->name); free(vcl->name);
(void)dlclose(vcl->dlh); (void)dlclose(vcl->dlh);
...@@ -336,7 +336,7 @@ ccf_config_use(struct cli *cli, const char * const *av, void *priv) ...@@ -336,7 +336,7 @@ ccf_config_use(struct cli *cli, const char * const *av, void *priv)
#define VCL_MET_MAC(func, upper, bitmap) \ #define VCL_MET_MAC(func, upper, bitmap) \
void \ void \
VCL_##func##_method(struct req *req) \ VCL_##func##_method(struct worker *wrk, struct req *req) \
{ \ { \
char *aws; \ char *aws; \
\ \
...@@ -347,7 +347,7 @@ VCL_##func##_method(struct req *req) \ ...@@ -347,7 +347,7 @@ VCL_##func##_method(struct req *req) \
req->handling = 0; \ req->handling = 0; \
req->cur_method = VCL_MET_ ## upper; \ req->cur_method = VCL_MET_ ## upper; \
VSLb(req->vsl, SLT_VCL_call, "%s", #func); \ VSLb(req->vsl, SLT_VCL_call, "%s", #func); \
(void)req->vcl->func##_func(req); \ (void)req->vcl->func##_func(wrk, req); \
VSLb(req->vsl, SLT_VCL_return, "%s", \ VSLb(req->vsl, SLT_VCL_return, "%s", \
VCL_Return_Name(req->handling)); \ VCL_Return_Name(req->handling)); \
req->cur_method = 0; \ req->cur_method = 0; \
......
...@@ -746,10 +746,11 @@ fo.write(""" ...@@ -746,10 +746,11 @@ fo.write("""
struct sess; struct sess;
struct req; struct req;
struct cli; struct cli;
struct worker;
typedef int vcl_init_f(struct cli *); typedef int vcl_init_f(struct cli *);
typedef void vcl_fini_f(struct cli *); typedef void vcl_fini_f(struct cli *);
typedef int vcl_func_f(struct req *req); typedef int vcl_func_f(struct worker *wrk, struct req *req);
""") """)
......
...@@ -692,7 +692,8 @@ vcc_CompileSource(const struct vcc *tl0, struct vsb *sb, struct source *sp) ...@@ -692,7 +692,8 @@ vcc_CompileSource(const struct vcc *tl0, struct vsb *sb, struct source *sp)
/* Emit method functions */ /* Emit method functions */
for (i = 0; i < VCL_MET_MAX; i++) { for (i = 0; i < VCL_MET_MAX; i++) {
Fc(tl, 1, "\nstatic int __match_proto__(vcl_func_f)\n"); Fc(tl, 1, "\nstatic int __match_proto__(vcl_func_f)\n");
Fc(tl, 1, "VGC_function_%s(struct req *req)\n", Fc(tl, 1,
"VGC_function_%s(struct worker *wrk, struct req *req)\n",
method_tab[i].name); method_tab[i].name);
AZ(VSB_finish(tl->fm[i])); AZ(VSB_finish(tl->fm[i]));
Fc(tl, 1, "{\n"); Fc(tl, 1, "{\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment