Commit 20a5abe7 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

move VCL::handling from req to wrk

parent d54e1ec9
...@@ -349,6 +349,7 @@ struct worker { ...@@ -349,6 +349,7 @@ struct worker {
struct vxid_pool vxid_pool; struct vxid_pool vxid_pool;
unsigned handling;
}; };
/* LRU ---------------------------------------------------------------*/ /* LRU ---------------------------------------------------------------*/
...@@ -613,7 +614,6 @@ struct req { ...@@ -613,7 +614,6 @@ struct req {
enum sess_close doclose; enum sess_close doclose;
struct exp exp; struct exp exp;
unsigned cur_method; unsigned cur_method;
unsigned handling;
unsigned char wantbody; unsigned char wantbody;
enum req_body_state_e req_body_status; enum req_body_state_e req_body_status;
......
...@@ -225,9 +225,15 @@ pan_vcl(const struct VCL_conf *vcl) ...@@ -225,9 +225,15 @@ pan_vcl(const struct VCL_conf *vcl)
static void static void
pan_wrk(const struct worker *wrk) pan_wrk(const struct worker *wrk)
{ {
const char *hand;
VSB_printf(pan_vsp, " worker = %p {\n", wrk); VSB_printf(pan_vsp, " worker = %p {\n", wrk);
pan_ws(wrk->aws, 4); 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"); VSB_printf(pan_vsp, " },\n");
} }
...@@ -261,7 +267,7 @@ pan_busyobj(const struct busyobj *bo) ...@@ -261,7 +267,7 @@ pan_busyobj(const struct busyobj *bo)
static void static void
pan_req(const struct req *req) pan_req(const struct req *req)
{ {
const char *hand, *stp, *body; const char *stp, *body;
VSB_printf(pan_vsp, "req = %p {\n", req); VSB_printf(pan_vsp, "req = %p {\n", req);
...@@ -290,11 +296,6 @@ pan_req(const struct req *req) ...@@ -290,11 +296,6 @@ pan_req(const struct req *req)
VSB_printf(pan_vsp, " req_body = 0x%x,\n", VSB_printf(pan_vsp, " req_body = 0x%x,\n",
req->req_body_status); 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) if (req->err_code)
VSB_printf(pan_vsp, VSB_printf(pan_vsp,
" err_code = %d, err_reason = %s,\n", req->err_code, " err_code = %d, err_reason = %s,\n", req->err_code,
......
...@@ -159,7 +159,7 @@ cnt_prepresp(struct worker *wrk, struct req *req) ...@@ -159,7 +159,7 @@ cnt_prepresp(struct worker *wrk, struct req *req)
RES_BuildHttp(req); RES_BuildHttp(req);
VCL_deliver_method(wrk, req, req->http->ws); VCL_deliver_method(wrk, req, req->http->ws);
switch (req->handling) { switch (wrk->handling) {
case VCL_RET_DELIVER: case VCL_RET_DELIVER:
break; break;
case VCL_RET_RESTART: case VCL_RET_RESTART:
...@@ -310,21 +310,21 @@ cnt_error(struct worker *wrk, struct req *req) ...@@ -310,21 +310,21 @@ cnt_error(struct worker *wrk, struct req *req)
http_PutResponse(h, http_StatusMessage(req->err_code)); http_PutResponse(h, http_StatusMessage(req->err_code));
VCL_error_method(wrk, req, req->http->ws); 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) { req->restarts < cache_param->max_restarts) {
HSH_Drop(wrk, &req->obj); HSH_Drop(wrk, &req->obj);
VBO_DerefBusyObj(wrk, &req->busyobj); VBO_DerefBusyObj(wrk, &req->busyobj);
req->req_step = R_STP_RESTART; req->req_step = R_STP_RESTART;
return (REQ_FSM_MORE); return (REQ_FSM_MORE);
} else if (req->handling == VCL_RET_RESTART) } else if (wrk->handling == VCL_RET_RESTART)
req->handling = VCL_RET_DELIVER; wrk->handling = VCL_RET_DELIVER;
/* We always close when we take this path */ /* We always close when we take this path */
req->doclose = SC_TX_ERROR; req->doclose = SC_TX_ERROR;
req->wantbody = 1; req->wantbody = 1;
assert(req->handling == VCL_RET_DELIVER); assert(wrk->handling == VCL_RET_DELIVER);
req->err_code = 0; req->err_code = 0;
req->err_reason = NULL; req->err_reason = NULL;
http_Teardown(bo->bereq); http_Teardown(bo->bereq);
...@@ -382,7 +382,7 @@ cnt_fetch(struct worker *wrk, struct req *req) ...@@ -382,7 +382,7 @@ cnt_fetch(struct worker *wrk, struct req *req)
} }
if (i) { if (i) {
req->handling = VCL_RET_ERROR; wrk->handling = VCL_RET_ERROR;
req->err_code = 503; req->err_code = 503;
} else { } else {
/* /*
...@@ -421,7 +421,7 @@ cnt_fetch(struct worker *wrk, struct req *req) ...@@ -421,7 +421,7 @@ cnt_fetch(struct worker *wrk, struct req *req)
if (bo->do_pass) if (bo->do_pass)
req->objcore->flags |= OC_F_PASS; req->objcore->flags |= OC_F_PASS;
switch (req->handling) { switch (wrk->handling) {
case VCL_RET_DELIVER: case VCL_RET_DELIVER:
req->req_step = R_STP_FETCHBODY; req->req_step = R_STP_FETCHBODY;
return (REQ_FSM_MORE); return (REQ_FSM_MORE);
...@@ -437,8 +437,8 @@ cnt_fetch(struct worker *wrk, struct req *req) ...@@ -437,8 +437,8 @@ cnt_fetch(struct worker *wrk, struct req *req)
AZ(bo->vbc); AZ(bo->vbc);
if (req->objcore->objhead != NULL || if (req->objcore->objhead != NULL ||
req->handling == VCL_RET_RESTART || wrk->handling == VCL_RET_RESTART ||
req->handling == VCL_RET_ERROR) { wrk->handling == VCL_RET_ERROR) {
CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC); CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC);
AZ(HSH_Deref(&wrk->stats, req->objcore, NULL)); AZ(HSH_Deref(&wrk->stats, req->objcore, NULL));
req->objcore = NULL; req->objcore = NULL;
...@@ -449,7 +449,7 @@ cnt_fetch(struct worker *wrk, struct req *req) ...@@ -449,7 +449,7 @@ cnt_fetch(struct worker *wrk, struct req *req)
req->director = NULL; req->director = NULL;
req->storage_hint = NULL; req->storage_hint = NULL;
switch (req->handling) { switch (wrk->handling) {
case VCL_RET_RESTART: case VCL_RET_RESTART:
req->req_step = R_STP_RESTART; req->req_step = R_STP_RESTART;
return (REQ_FSM_MORE); return (REQ_FSM_MORE);
...@@ -491,7 +491,7 @@ cnt_fetchbody(struct worker *wrk, struct req *req) ...@@ -491,7 +491,7 @@ cnt_fetchbody(struct worker *wrk, struct req *req)
bo = req->busyobj; bo = req->busyobj;
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
assert(req->handling == VCL_RET_DELIVER); assert(wrk->handling == VCL_RET_DELIVER);
if (req->objcore->objhead == NULL) { if (req->objcore->objhead == NULL) {
/* This is a pass from vcl_recv */ /* This is a pass from vcl_recv */
...@@ -848,14 +848,14 @@ VSLb(req->vsl, SLT_Debug, "XXXX HIT\n"); ...@@ -848,14 +848,14 @@ VSLb(req->vsl, SLT_Debug, "XXXX HIT\n");
VCL_lookup_method(wrk, req, req->http->ws); VCL_lookup_method(wrk, req, req->http->ws);
if ((req->obj->objcore->flags & OC_F_PASS) && if ((req->obj->objcore->flags & OC_F_PASS) &&
req->handling == VCL_RET_DELIVER) { wrk->handling == VCL_RET_DELIVER) {
VSLb(req->vsl, SLT_VCL_Error, VSLb(req->vsl, SLT_VCL_Error,
"obj.uncacheable set, but vcl_lookup{} returned 'deliver'" "obj.uncacheable set, but vcl_lookup{} returned 'deliver'"
", changing to 'pass'"); ", 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->bereq->ws);
//AZ(req->busyobj->beresp->ws); //AZ(req->busyobj->beresp->ws);
(void)HTTP1_DiscardReqBody(req); // XXX: handle err (void)HTTP1_DiscardReqBody(req); // XXX: handle err
...@@ -867,7 +867,7 @@ VSLb(req->vsl, SLT_Debug, "XXXX HIT\n"); ...@@ -867,7 +867,7 @@ VSLb(req->vsl, SLT_Debug, "XXXX HIT\n");
(void)HSH_Deref(&wrk->stats, NULL, &req->obj); (void)HSH_Deref(&wrk->stats, NULL, &req->obj);
req->objcore = NULL; req->objcore = NULL;
switch(req->handling) { switch(wrk->handling) {
case VCL_RET_PASS: case VCL_RET_PASS:
req->req_step = R_STP_PASS; req->req_step = R_STP_PASS;
break; break;
...@@ -926,7 +926,7 @@ cnt_miss(struct worker *wrk, struct req *req) ...@@ -926,7 +926,7 @@ cnt_miss(struct worker *wrk, struct req *req)
VCL_fetch_method(wrk, req, req->http->ws); VCL_fetch_method(wrk, req, req->http->ws);
VCL_miss_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); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
req->req_step = R_STP_FETCH; req->req_step = R_STP_FETCH;
return (REQ_FSM_MORE); return (REQ_FSM_MORE);
...@@ -937,7 +937,7 @@ cnt_miss(struct worker *wrk, struct req *req) ...@@ -937,7 +937,7 @@ cnt_miss(struct worker *wrk, struct req *req)
http_Teardown(bo->bereq); http_Teardown(bo->bereq);
VBO_DerefBusyObj(wrk, &req->busyobj); VBO_DerefBusyObj(wrk, &req->busyobj);
switch(req->handling) { switch(wrk->handling) {
case VCL_RET_ERROR: case VCL_RET_ERROR:
req->req_step = R_STP_ERROR; req->req_step = R_STP_ERROR;
break; break;
...@@ -991,13 +991,13 @@ cnt_pass(struct worker *wrk, struct req *req) ...@@ -991,13 +991,13 @@ cnt_pass(struct worker *wrk, struct req *req)
VCL_fetch_method(wrk, req, req->http->ws); VCL_fetch_method(wrk, req, req->http->ws);
VCL_pass_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); http_Teardown(bo->bereq);
VBO_DerefBusyObj(wrk, &req->busyobj); VBO_DerefBusyObj(wrk, &req->busyobj);
req->req_step = R_STP_ERROR; req->req_step = R_STP_ERROR;
return (REQ_FSM_MORE); return (REQ_FSM_MORE);
} }
assert(req->handling == VCL_RET_PASS); assert(wrk->handling == VCL_RET_PASS);
req->acct_req.pass++; req->acct_req.pass++;
req->req_step = R_STP_FETCH; req->req_step = R_STP_FETCH;
...@@ -1049,9 +1049,9 @@ cnt_pipe(struct worker *wrk, struct req *req) ...@@ -1049,9 +1049,9 @@ cnt_pipe(struct worker *wrk, struct req *req)
VCL_pipe_method(wrk, req, req->http->ws); VCL_pipe_method(wrk, req, req->http->ws);
if (req->handling == VCL_RET_ERROR) if (wrk->handling == VCL_RET_ERROR)
INCOMPL(); INCOMPL();
assert(req->handling == VCL_RET_PIPE); assert(wrk->handling == VCL_RET_PIPE);
PipeRequest(req); PipeRequest(req);
assert(WRW_IsReleased(wrk)); assert(WRW_IsReleased(wrk));
...@@ -1154,7 +1154,7 @@ cnt_recv(struct worker *wrk, struct req *req) ...@@ -1154,7 +1154,7 @@ cnt_recv(struct worker *wrk, struct req *req)
http_CollectHdr(req->http, H_Cache_Control); http_CollectHdr(req->http, H_Cache_Control);
VCL_recv_method(wrk, req, req->http->ws); VCL_recv_method(wrk, req, req->http->ws);
recv_handling = req->handling; recv_handling = wrk->handling;
if (cache_param->http_gzip_support && if (cache_param->http_gzip_support &&
(recv_handling != VCL_RET_PIPE) && (recv_handling != VCL_RET_PIPE) &&
...@@ -1170,7 +1170,7 @@ cnt_recv(struct worker *wrk, struct req *req) ...@@ -1170,7 +1170,7 @@ cnt_recv(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(wrk, req, req->http->ws); 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); SHA256_Final(req->digest, req->sha256ctx);
req->sha256ctx = NULL; req->sha256ctx = NULL;
......
...@@ -345,15 +345,15 @@ VCL_##func##_method(struct worker *wrk, struct req *req, struct ws *ws) \ ...@@ -345,15 +345,15 @@ VCL_##func##_method(struct worker *wrk, struct req *req, struct ws *ws) \
CHECK_OBJ_NOTNULL(req->sp, SESS_MAGIC); \ CHECK_OBJ_NOTNULL(req->sp, SESS_MAGIC); \
AN(req->sp); \ AN(req->sp); \
aws = WS_Snapshot(wrk->aws); \ aws = WS_Snapshot(wrk->aws); \
req->handling = 0; \ wrk->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(wrk, req, NULL, ws); \ (void)req->vcl->func##_func(wrk, req, NULL, ws); \
VSLb(req->vsl, SLT_VCL_return, "%s", \ VSLb(req->vsl, SLT_VCL_return, "%s", \
VCL_Return_Name(req->handling)); \ VCL_Return_Name(wrk->handling)); \
req->cur_method = 0; \ req->cur_method = 0; \
assert((1U << req->handling) & bitmap); \ assert((1U << wrk->handling) & bitmap); \
assert(!((1U << req->handling) & ~bitmap)); \ assert(!((1U << wrk->handling) & ~bitmap)); \
WS_Reset(wrk->aws, aws); \ WS_Reset(wrk->aws, aws); \
} }
......
...@@ -258,16 +258,16 @@ VRT_SetHdr(struct req *req , const struct gethdr_s *hs, const char *p, ...) ...@@ -258,16 +258,16 @@ VRT_SetHdr(struct req *req , const struct gethdr_s *hs, const char *p, ...)
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
void 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); assert(hand == VCL_RET_OK);
return; return;
} }
CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
assert(hand < VCL_RET_MAX); assert(hand < VCL_RET_MAX);
req->handling = hand; wrk->handling = hand;
} }
/*-------------------------------------------------------------------- /*--------------------------------------------------------------------
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
*/ */
struct req; struct req;
struct worker;
struct ws; struct ws;
struct vsb; struct vsb;
struct cli; struct cli;
...@@ -179,7 +180,7 @@ int VRT_switch_config(const char *); ...@@ -179,7 +180,7 @@ int VRT_switch_config(const char *);
const struct gethdr_s *VRT_MkGethdr(struct req *,enum gethdr_e, 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 *); char *VRT_GetHdr(const struct req *, const struct gethdr_s *);
void VRT_SetHdr(struct req *, const struct gethdr_s *, const char *, ...); 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, ...); void VRT_hashdata(struct req *, const char *str, ...);
...@@ -231,10 +232,4 @@ char *VRT_TIME_string(struct ws *, double); ...@@ -231,10 +232,4 @@ char *VRT_TIME_string(struct ws *, double);
const char *VRT_BOOL_string(unsigned); const char *VRT_BOOL_string(unsigned);
const char *VRT_BACKEND_string(const struct director *d); 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, ...); const char *VRT_ReqString(struct req *, const char *p, ...);
...@@ -79,7 +79,8 @@ parse_error(struct vcc *tl) ...@@ -79,7 +79,8 @@ parse_error(struct vcc *tl)
Fb(tl, 1, ", 0\n"); Fb(tl, 1, ", 0\n");
} }
Fb(tl, 1, ");\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) ...@@ -311,7 +312,8 @@ parse_return(struct vcc *tl)
#define VCL_RET_MAC(l, U, B) \ #define VCL_RET_MAC(l, U, B) \
do { \ do { \
if (vcc_IdIs(tl->t, #l)) { \ 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);\ vcc_ProcAction(tl->curproc, VCL_RET_##U, tl->t);\
retval = 1; \ retval = 1; \
} \ } \
......
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