[master] ae6dfe2e2 Further reduce transport code frobbing of req->req_step

Poul-Henning Kamp phk at FreeBSD.org
Mon Oct 26 09:14:06 UTC 2020


commit ae6dfe2e2fc2973163fc7927f98b042918bf04d1
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Oct 26 09:12:28 2020 +0000

    Further reduce transport code frobbing of req->req_step

diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c
index 66dbb8c22..5e702a3be 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -187,10 +187,10 @@ ved_include(struct req *preq, const char *src, const char *host,
 	req->transport = &VED_transport;
 	req->transport_priv = ecx;
 
-	CNT_Embark(wrk, req);
 	VCL_TaskEnter(req->privs);
 
 	while (1) {
+		CNT_Embark(wrk, req);
 		ecx->woken = 0;
 		s = CNT_Request(req);
 		if (s == REQ_FSM_DONE)
@@ -204,7 +204,6 @@ ved_include(struct req *preq, const char *src, const char *host,
 			    &ecx->preq->wrk->cond, &sp->mtx, 0);
 		Lck_Unlock(&sp->mtx);
 		AZ(req->wrk);
-		CNT_Embark(wrk, req);
 	}
 
 	VCL_Rel(&req->vcl);
diff --git a/bin/varnishd/cache/cache_req.c b/bin/varnishd/cache/cache_req.c
index 0592318b4..0a3bc65a5 100644
--- a/bin/varnishd/cache/cache_req.c
+++ b/bin/varnishd/cache/cache_req.c
@@ -250,6 +250,7 @@ Req_Cleanup(struct sess *sp, struct worker *wrk, struct req *req)
 	req->hash_ignore_busy = 0;
 	req->esi_level = 0;
 	req->is_hit = 0;
+	req->req_step = R_STP_TRANSPORT;
 
 	if (WS_Overflowed(req->ws))
 		wrk->stats->ws_client_overflow++;
diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c
index 9625bed21..de3662f1e 100644
--- a/bin/varnishd/http1/cache_http1_fsm.c
+++ b/bin/varnishd/http1/cache_http1_fsm.c
@@ -389,17 +389,15 @@ HTTP1_Session(struct worker *wrk, struct req *req)
 					return;
 				}
 			}
-			req->req_step = R_STP_TRANSPORT;
+			assert(req->req_step == R_STP_TRANSPORT);
+			VCL_TaskEnter(req->privs);
+			VCL_TaskEnter(req->top->privs);
 			http1_setstate(sp, H1PROC);
 		} else if (st == H1PROC) {
 			req->task->func = http1_req;
 			req->task->priv = req;
 			wrk->stats->client_req++;
 			CNT_Embark(wrk, req);
-			if (req->req_step == R_STP_TRANSPORT) {
-				VCL_TaskEnter(req->privs);
-				VCL_TaskEnter(req->top->privs);
-			}
 			if (CNT_Request(req) == REQ_FSM_DISEMBARK)
 				return;
 			AZ(req->top->vcl0);
diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c
index 80993232c..614d13781 100644
--- a/bin/varnishd/http2/cache_http2_proto.c
+++ b/bin/varnishd/http2/cache_http2_proto.c
@@ -525,10 +525,6 @@ h2_do_req(struct worker *wrk, void *priv)
 	CAST_OBJ_NOTNULL(r2, req->transport_priv, H2_REQ_MAGIC);
 	THR_SetRequest(req);
 	CNT_Embark(wrk, req);
-	if (req->req_step == R_STP_TRANSPORT) {
-		VCL_TaskEnter(req->privs);
-		VCL_TaskEnter(req->top->privs);
-	}
 
 	wrk->stats->client_req++;
 	if (CNT_Request(req) != REQ_FSM_DISEMBARK) {
@@ -598,6 +594,8 @@ h2_end_headers(struct worker *wrk, struct h2_sess *h2,
 	AN(req->http->hd[HTTP_HDR_PROTO].b);
 
 	assert(req->req_step == R_STP_TRANSPORT);
+	VCL_TaskEnter(req->privs);
+	VCL_TaskEnter(req->top->privs);
 	req->task->func = h2_do_req;
 	req->task->priv = req;
 	r2->scheduled = 1;


More information about the varnish-commit mailing list