[master] 20d356b3d tranport: Increment MAIN.client_req exactly once
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Mon Sep 12 14:03:11 UTC 2022
commit 20d356b3d08a458c6f56117a65f9041b5f6fd405
Author: Lachlan Abbott <lachie at varnish-software.com>
Date: Wed Sep 7 16:43:34 2022 +1000
tranport: Increment MAIN.client_req exactly once
When a request comes back from the waiting list, it is accounted for in
the client_req counter, despite not being a new request. To avoid the
spurious increments, a request is counted only after leaving the state
machine for good. This has no effect on when the client_req increment
becomes visible since it is part of the "wrk" group in the first place.
In 2e66e0b93ba6e50fa5ef499cd6a4860d0fa56134 the client_req increment was
moved from the request state machine (R_STP_TRANSPORT) to individual
transport. This patch can't be reverted because shortly aftwerwards the
ESI transport changed in 2c59afe22ba108c7f2ab5ff75b2e30baf4ef9ec7 and
now runs the R_STP_TRANSPORT step and the client_req counter does not
count sub-requests.
Refs 2e66e0b93ba6e50fa5ef499cd6a4860d0fa56134
Refs 2c59afe22ba108c7f2ab5ff75b2e30baf4ef9ec7
diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c
index cc61649fd..ab92dcf38 100644
--- a/bin/varnishd/http1/cache_http1_fsm.c
+++ b/bin/varnishd/http1/cache_http1_fsm.c
@@ -386,10 +386,10 @@ HTTP1_Session(struct worker *wrk, struct req *req)
} else if (st == H1PROC) {
req->task->func = http1_req;
req->task->priv = req;
- wrk->stats->client_req++;
CNT_Embark(wrk, req);
if (CNT_Request(req) == REQ_FSM_DISEMBARK)
return;
+ wrk->stats->client_req++;
AZ(req->top->vcl0);
req->task->func = NULL;
req->task->priv = NULL;
diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c
index c408acd65..63c491fbd 100644
--- a/bin/varnishd/http2/cache_http2_proto.c
+++ b/bin/varnishd/http2/cache_http2_proto.c
@@ -540,8 +540,8 @@ h2_do_req(struct worker *wrk, void *priv)
THR_SetRequest(req);
CNT_Embark(wrk, req);
- wrk->stats->client_req++;
if (CNT_Request(req) != REQ_FSM_DISEMBARK) {
+ wrk->stats->client_req++;
assert(!WS_IsReserved(req->ws));
AZ(req->top->vcl0);
h2 = r2->h2sess;
diff --git a/bin/varnishtest/tests/c00013.vtc b/bin/varnishtest/tests/c00013.vtc
index ef4cc76f8..be2a734c9 100644
--- a/bin/varnishtest/tests/c00013.vtc
+++ b/bin/varnishtest/tests/c00013.vtc
@@ -47,6 +47,7 @@ client c2 {
client c1 -wait
varnish v1 -vsl_catchup
+varnish v1 -expect client_req == 2
varnish v1 -expect busy_sleep >= 1
varnish v1 -expect busy_wakeup >= 1
varnish v1 -stop
diff --git a/bin/varnishtest/tests/t02009.vtc b/bin/varnishtest/tests/t02009.vtc
index 511f54f67..223149531 100644
--- a/bin/varnishtest/tests/t02009.vtc
+++ b/bin/varnishtest/tests/t02009.vtc
@@ -29,3 +29,5 @@ client c1 {
} -run
stream 1 -wait
} -run
+
+varnish v1 -expect client_req == 2
More information about the varnish-commit
mailing list