Commit 3da2ed68 authored by Nils Goroll's avatar Nils Goroll

ensure consistent req init for vcl switching

Merges #2447
parent c2406f4f
......@@ -738,35 +738,15 @@ cnt_restart(struct worker *wrk, struct req *req)
return (REQ_FSM_MORE);
}
/*--------------------------------------------------------------------
* We have a complete request, set everything up and start it.
* We can come here both with a request from the client and with
* a interior request during ESI delivery.
/*
* prepare the request for vcl_recv, either initially or after a reset
* e.g. due to vcl switching
*/
static enum req_fsm_nxt
cnt_recv(struct worker *wrk, struct req *req)
static void
cnt_recv_prep(struct req *req, const char *ci)
{
unsigned recv_handling;
struct VSHA256Context sha256ctx;
const char *xff;
const char *ci, *cp;
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
AN(req->vcl);
AZ(req->objcore);
AZ(req->err_code);
AZ(isnan(req->t_first));
AZ(isnan(req->t_prev));
AZ(isnan(req->t_req));
ci = SES_Get_String_Attr(req->sp, SA_CLIENT_IP);
cp = SES_Get_String_Attr(req->sp, SA_CLIENT_PORT);
VSLb(req->vsl, SLT_ReqStart, "%s %s", ci, cp);
http_VSL_log(req->http);
if (req->restarts == 0) {
/*
......@@ -784,7 +764,6 @@ cnt_recv(struct worker *wrk, struct req *req)
http_CollectHdr(req->http, H_Cache_Control);
/* By default we use the first backend */
AZ(req->director_hint);
req->director_hint = VCL_DefaultDirector(req->vcl);
AN(req->director_hint);
......@@ -798,6 +777,37 @@ cnt_recv(struct worker *wrk, struct req *req)
req->vdc->retval = 0;
req->is_hit = 0;
}
/*--------------------------------------------------------------------
* We have a complete request, set everything up and start it.
* We can come here both with a request from the client and with
* a interior request during ESI delivery.
*/
static enum req_fsm_nxt
cnt_recv(struct worker *wrk, struct req *req)
{
unsigned recv_handling;
struct VSHA256Context sha256ctx;
const char *ci, *cp;
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
AN(req->vcl);
AZ(req->objcore);
AZ(req->err_code);
AZ(isnan(req->t_first));
AZ(isnan(req->t_prev));
AZ(isnan(req->t_req));
ci = SES_Get_String_Attr(req->sp, SA_CLIENT_IP);
cp = SES_Get_String_Attr(req->sp, SA_CLIENT_PORT);
VSLb(req->vsl, SLT_ReqStart, "%s %s", ci, cp);
http_VSL_log(req->http);
cnt_recv_prep(req, ci);
if (req->req_body_status == REQ_BODY_FAIL) {
req->doclose = SC_OVERLOAD;
......@@ -806,10 +816,9 @@ cnt_recv(struct worker *wrk, struct req *req)
VCL_recv_method(req->vcl, wrk, req, NULL, NULL);
if (wrk->handling == VCL_RET_VCL && req->restarts == 0) {
req->director_hint = VCL_DefaultDirector(req->vcl);
HTTP_Copy(req->http, req->http0);
WS_Reset(req->ws, req->ws_req);
AN(req->director_hint);
cnt_recv_prep(req, ci);
VCL_recv_method(req->vcl, wrk, req, NULL, NULL);
}
......
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