[master] 3da2ed6 ensure consistent req init for vcl switching
Nils Goroll
nils.goroll at uplex.de
Tue Nov 7 11:29:06 UTC 2017
commit 3da2ed68340ae85bf774352bff93e73926d854dc
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Mon Oct 2 16:40:56 2017 +0200
ensure consistent req init for vcl switching
Merges #2447
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index e97ce19..cbf3576 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -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);
}
More information about the varnish-commit
mailing list