[master] 2fe1e1aa9 Centralize the req borrowing VCL from wrk

Poul-Henning Kamp phk at FreeBSD.org
Mon Dec 10 11:40:10 UTC 2018


commit 2fe1e1aa91af45277da5cdc41bc458b4a97a17d9
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Dec 10 10:23:30 2018 +0000

    Centralize the req borrowing VCL from wrk

diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 20a219f38..69b5f8dd4 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -821,6 +821,7 @@ cnt_recv_prep(struct req *req, const char *ci)
 	req->is_hitmiss = 0;
 	req->is_hitpass = 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
@@ -1026,7 +1027,6 @@ CNT_Request(struct worker *wrk, struct req *req)
 
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
-	AN(req->vcl);
 
 	/*
 	 * Possible entrance states
@@ -1041,6 +1041,13 @@ CNT_Request(struct worker *wrk, struct req *req)
 	/* wrk can have changed for restarts */
 	req->vfc->wrk = req->wrk = wrk;
 	wrk->vsl = req->vsl;
+	if (req->req_step == R_STP_TRANSPORT) {
+		AZ(req->vcl);
+		VCL_Refresh(&wrk->vcl);
+		req->vcl = wrk->vcl;
+		wrk->vcl = NULL;
+	}
+	AN(req->vcl);
 	if (req->req_step != R_STP_LOOKUP)
 		VCL_TaskEnter(req->vcl, req->privs);
 	for (nxt = REQ_FSM_MORE; nxt == REQ_FSM_MORE; ) {
diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c
index a6693f662..7210ab761 100644
--- a/bin/varnishd/http1/cache_http1_fsm.c
+++ b/bin/varnishd/http1/cache_http1_fsm.c
@@ -281,11 +281,6 @@ http1_dissect(struct worker *wrk, struct req *req)
 	VSLb_ts_req(req, "Start", req->t_first);
 	VSLb_ts_req(req, "Req", req->t_req);
 
-	/* Borrow VCL reference from worker thread */
-	VCL_Refresh(&wrk->vcl);
-	req->vcl = wrk->vcl;
-	wrk->vcl = NULL;
-
 	HTTP_Setup(req->http, req->ws, req->vsl, SLT_ReqMethod);
 	req->err_code = HTTP1_DissectRequest(req->htc, req->http);
 
diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c
index 7d040b7d0..0ff9b03a6 100644
--- a/bin/varnishd/http2/cache_http2_proto.c
+++ b/bin/varnishd/http2/cache_http2_proto.c
@@ -661,9 +661,6 @@ h2_rx_headers(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2)
 	req->t_req = VTIM_real();
 	req->t_prev = req->t_first;
 	VSLb_ts_req(req, "Start", req->t_first);
-	VCL_Refresh(&wrk->vcl);
-	req->vcl = wrk->vcl;
-	wrk->vcl = NULL;
 	req->acct.req_hdrbytes += h2->rxf_len;
 
 	HTTP_Setup(req->http, req->ws, req->vsl, SLT_ReqMethod);
diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c
index 8828c146e..115ec6b8d 100644
--- a/bin/varnishd/http2/cache_http2_session.c
+++ b/bin/varnishd/http2/cache_http2_session.c
@@ -239,8 +239,7 @@ h2_ou_rel(struct worker *wrk, struct req *req)
 {
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
-	AN (req->vcl);
-	VCL_Rel(&req->vcl);
+	AZ(req->vcl);
 	Req_AcctLogCharge(wrk->stats, req);
 	Req_Release(req);
 	return (0);


More information about the varnish-commit mailing list