[master] 20a5abe move VCL::handling from req to wrk
Poul-Henning Kamp
phk at varnish-cache.org
Mon Apr 22 08:52:27 CEST 2013
commit 20a5abe7b911d135ccbe78b0dd05c673e1b40f61
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Apr 22 06:52:18 2013 +0000
move VCL::handling from req to wrk
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 051defb..1b67d88 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -349,6 +349,7 @@ struct worker {
struct vxid_pool vxid_pool;
+ unsigned handling;
};
/* LRU ---------------------------------------------------------------*/
@@ -613,7 +614,6 @@ struct req {
enum sess_close doclose;
struct exp exp;
unsigned cur_method;
- unsigned handling;
unsigned char wantbody;
enum req_body_state_e req_body_status;
diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c
index 1781789..bc3accf 100644
--- a/bin/varnishd/cache/cache_panic.c
+++ b/bin/varnishd/cache/cache_panic.c
@@ -225,9 +225,15 @@ pan_vcl(const struct VCL_conf *vcl)
static void
pan_wrk(const struct worker *wrk)
{
+ const char *hand;
VSB_printf(pan_vsp, " worker = %p {\n", wrk);
pan_ws(wrk->aws, 4);
+ hand = VCL_Return_Name(wrk->handling);
+ if (hand != NULL)
+ VSB_printf(pan_vsp, " handling = %s,\n", hand);
+ else
+ VSB_printf(pan_vsp, " handling = 0x%x,\n", wrk->handling);
VSB_printf(pan_vsp, " },\n");
}
@@ -261,7 +267,7 @@ pan_busyobj(const struct busyobj *bo)
static void
pan_req(const struct req *req)
{
- const char *hand, *stp, *body;
+ const char *stp, *body;
VSB_printf(pan_vsp, "req = %p {\n", req);
@@ -290,11 +296,6 @@ pan_req(const struct req *req)
VSB_printf(pan_vsp, " req_body = 0x%x,\n",
req->req_body_status);
- hand = VCL_Return_Name(req->handling);
- if (hand != NULL)
- VSB_printf(pan_vsp, " handling = %s,\n", hand);
- else
- VSB_printf(pan_vsp, " handling = 0x%x,\n", req->handling);
if (req->err_code)
VSB_printf(pan_vsp,
" err_code = %d, err_reason = %s,\n", req->err_code,
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 2df6dd8..8d2b40c 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -159,7 +159,7 @@ cnt_prepresp(struct worker *wrk, struct req *req)
RES_BuildHttp(req);
VCL_deliver_method(wrk, req, req->http->ws);
- switch (req->handling) {
+ switch (wrk->handling) {
case VCL_RET_DELIVER:
break;
case VCL_RET_RESTART:
@@ -310,21 +310,21 @@ cnt_error(struct worker *wrk, struct req *req)
http_PutResponse(h, http_StatusMessage(req->err_code));
VCL_error_method(wrk, req, req->http->ws);
- if (req->handling == VCL_RET_RESTART &&
+ if (wrk->handling == VCL_RET_RESTART &&
req->restarts < cache_param->max_restarts) {
HSH_Drop(wrk, &req->obj);
VBO_DerefBusyObj(wrk, &req->busyobj);
req->req_step = R_STP_RESTART;
return (REQ_FSM_MORE);
- } else if (req->handling == VCL_RET_RESTART)
- req->handling = VCL_RET_DELIVER;
+ } else if (wrk->handling == VCL_RET_RESTART)
+ wrk->handling = VCL_RET_DELIVER;
/* We always close when we take this path */
req->doclose = SC_TX_ERROR;
req->wantbody = 1;
- assert(req->handling == VCL_RET_DELIVER);
+ assert(wrk->handling == VCL_RET_DELIVER);
req->err_code = 0;
req->err_reason = NULL;
http_Teardown(bo->bereq);
@@ -382,7 +382,7 @@ cnt_fetch(struct worker *wrk, struct req *req)
}
if (i) {
- req->handling = VCL_RET_ERROR;
+ wrk->handling = VCL_RET_ERROR;
req->err_code = 503;
} else {
/*
@@ -421,7 +421,7 @@ cnt_fetch(struct worker *wrk, struct req *req)
if (bo->do_pass)
req->objcore->flags |= OC_F_PASS;
- switch (req->handling) {
+ switch (wrk->handling) {
case VCL_RET_DELIVER:
req->req_step = R_STP_FETCHBODY;
return (REQ_FSM_MORE);
@@ -437,8 +437,8 @@ cnt_fetch(struct worker *wrk, struct req *req)
AZ(bo->vbc);
if (req->objcore->objhead != NULL ||
- req->handling == VCL_RET_RESTART ||
- req->handling == VCL_RET_ERROR) {
+ wrk->handling == VCL_RET_RESTART ||
+ wrk->handling == VCL_RET_ERROR) {
CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC);
AZ(HSH_Deref(&wrk->stats, req->objcore, NULL));
req->objcore = NULL;
@@ -449,7 +449,7 @@ cnt_fetch(struct worker *wrk, struct req *req)
req->director = NULL;
req->storage_hint = NULL;
- switch (req->handling) {
+ switch (wrk->handling) {
case VCL_RET_RESTART:
req->req_step = R_STP_RESTART;
return (REQ_FSM_MORE);
@@ -491,7 +491,7 @@ cnt_fetchbody(struct worker *wrk, struct req *req)
bo = req->busyobj;
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
- assert(req->handling == VCL_RET_DELIVER);
+ assert(wrk->handling == VCL_RET_DELIVER);
if (req->objcore->objhead == NULL) {
/* This is a pass from vcl_recv */
@@ -848,14 +848,14 @@ VSLb(req->vsl, SLT_Debug, "XXXX HIT\n");
VCL_lookup_method(wrk, req, req->http->ws);
if ((req->obj->objcore->flags & OC_F_PASS) &&
- req->handling == VCL_RET_DELIVER) {
+ wrk->handling == VCL_RET_DELIVER) {
VSLb(req->vsl, SLT_VCL_Error,
"obj.uncacheable set, but vcl_lookup{} returned 'deliver'"
", changing to 'pass'");
- req->handling = VCL_RET_PASS;
+ wrk->handling = VCL_RET_PASS;
}
- if (req->handling == VCL_RET_DELIVER) {
+ if (wrk->handling == VCL_RET_DELIVER) {
//AZ(req->busyobj->bereq->ws);
//AZ(req->busyobj->beresp->ws);
(void)HTTP1_DiscardReqBody(req); // XXX: handle err
@@ -867,7 +867,7 @@ VSLb(req->vsl, SLT_Debug, "XXXX HIT\n");
(void)HSH_Deref(&wrk->stats, NULL, &req->obj);
req->objcore = NULL;
- switch(req->handling) {
+ switch(wrk->handling) {
case VCL_RET_PASS:
req->req_step = R_STP_PASS;
break;
@@ -926,7 +926,7 @@ cnt_miss(struct worker *wrk, struct req *req)
VCL_fetch_method(wrk, req, req->http->ws);
VCL_miss_method(wrk, req, req->http->ws);
- if (req->handling == VCL_RET_FETCH) {
+ if (wrk->handling == VCL_RET_FETCH) {
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
req->req_step = R_STP_FETCH;
return (REQ_FSM_MORE);
@@ -937,7 +937,7 @@ cnt_miss(struct worker *wrk, struct req *req)
http_Teardown(bo->bereq);
VBO_DerefBusyObj(wrk, &req->busyobj);
- switch(req->handling) {
+ switch(wrk->handling) {
case VCL_RET_ERROR:
req->req_step = R_STP_ERROR;
break;
@@ -991,13 +991,13 @@ cnt_pass(struct worker *wrk, struct req *req)
VCL_fetch_method(wrk, req, req->http->ws);
VCL_pass_method(wrk, req, req->http->ws);
- if (req->handling == VCL_RET_ERROR) {
+ if (wrk->handling == VCL_RET_ERROR) {
http_Teardown(bo->bereq);
VBO_DerefBusyObj(wrk, &req->busyobj);
req->req_step = R_STP_ERROR;
return (REQ_FSM_MORE);
}
- assert(req->handling == VCL_RET_PASS);
+ assert(wrk->handling == VCL_RET_PASS);
req->acct_req.pass++;
req->req_step = R_STP_FETCH;
@@ -1049,9 +1049,9 @@ cnt_pipe(struct worker *wrk, struct req *req)
VCL_pipe_method(wrk, req, req->http->ws);
- if (req->handling == VCL_RET_ERROR)
+ if (wrk->handling == VCL_RET_ERROR)
INCOMPL();
- assert(req->handling == VCL_RET_PIPE);
+ assert(wrk->handling == VCL_RET_PIPE);
PipeRequest(req);
assert(WRW_IsReleased(wrk));
@@ -1154,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);
- recv_handling = req->handling;
+ recv_handling = wrk->handling;
if (cache_param->http_gzip_support &&
(recv_handling != VCL_RET_PIPE) &&
@@ -1170,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);
- assert(req->handling == VCL_RET_HASH);
+ 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 502e1b7..723da03 100644
--- a/bin/varnishd/cache/cache_vcl.c
+++ b/bin/varnishd/cache/cache_vcl.c
@@ -345,15 +345,15 @@ VCL_##func##_method(struct worker *wrk, struct req *req, struct ws *ws) \
CHECK_OBJ_NOTNULL(req->sp, SESS_MAGIC); \
AN(req->sp); \
aws = WS_Snapshot(wrk->aws); \
- req->handling = 0; \
+ wrk->handling = 0; \
req->cur_method = VCL_MET_ ## upper; \
VSLb(req->vsl, SLT_VCL_call, "%s", #func); \
(void)req->vcl->func##_func(wrk, req, NULL, ws); \
VSLb(req->vsl, SLT_VCL_return, "%s", \
- VCL_Return_Name(req->handling)); \
+ VCL_Return_Name(wrk->handling)); \
req->cur_method = 0; \
- assert((1U << req->handling) & bitmap); \
- assert(!((1U << req->handling) & ~bitmap)); \
+ assert((1U << wrk->handling) & bitmap); \
+ assert(!((1U << wrk->handling) & ~bitmap)); \
WS_Reset(wrk->aws, aws); \
}
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index df705cb..622d6c8 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -258,16 +258,16 @@ VRT_SetHdr(struct req *req , const struct gethdr_s *hs, const char *p, ...)
/*--------------------------------------------------------------------*/
void
-VRT_handling(struct req *req, unsigned hand)
+VRT_handling(struct worker *wrk, unsigned hand)
{
- if (req == NULL) {
+ if (wrk == NULL) {
assert(hand == VCL_RET_OK);
return;
}
- CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+ CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
assert(hand < VCL_RET_MAX);
- req->handling = hand;
+ wrk->handling = hand;
}
/*--------------------------------------------------------------------
diff --git a/include/vrt.h b/include/vrt.h
index 3d769b1..1b4d189 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -32,6 +32,7 @@
*/
struct req;
+struct worker;
struct ws;
struct vsb;
struct cli;
@@ -179,7 +180,7 @@ int VRT_switch_config(const char *);
const struct gethdr_s *VRT_MkGethdr(struct req *,enum gethdr_e, const char *);
char *VRT_GetHdr(const struct req *, const struct gethdr_s *);
void VRT_SetHdr(struct req *, const struct gethdr_s *, const char *, ...);
-void VRT_handling(struct req *, unsigned hand);
+void VRT_handling(struct worker *, unsigned hand);
void VRT_hashdata(struct req *, const char *str, ...);
@@ -231,10 +232,4 @@ char *VRT_TIME_string(struct ws *, double);
const char *VRT_BOOL_string(unsigned);
const char *VRT_BACKEND_string(const struct director *d);
-#define VRT_done(req, hand) \
- do { \
- VRT_handling(req, hand); \
- return (1); \
- } while (0)
-
const char *VRT_ReqString(struct req *, const char *p, ...);
diff --git a/lib/libvcl/vcc_action.c b/lib/libvcl/vcc_action.c
index a912188..baa5f29 100644
--- a/lib/libvcl/vcc_action.c
+++ b/lib/libvcl/vcc_action.c
@@ -79,7 +79,8 @@ parse_error(struct vcc *tl)
Fb(tl, 1, ", 0\n");
}
Fb(tl, 1, ");\n");
- Fb(tl, 1, "VRT_done(req, VCL_RET_ERROR);\n");
+ Fb(tl, 1, "VRT_handling(wrk, VCL_RET_ERROR);\n");
+ Fb(tl, 1, "return(1);\n");
}
/*--------------------------------------------------------------------*/
@@ -311,7 +312,8 @@ parse_return(struct vcc *tl)
#define VCL_RET_MAC(l, U, B) \
do { \
if (vcc_IdIs(tl->t, #l)) { \
- Fb(tl, 1, "VRT_done(req, VCL_RET_" #U ");\n"); \
+ Fb(tl, 1, "VRT_handling(wrk, VCL_RET_" #U ");\n"); \
+ Fb(tl, 1, "return (1);\n"); \
vcc_ProcAction(tl->curproc, VCL_RET_##U, tl->t);\
retval = 1; \
} \
More information about the varnish-commit
mailing list