]> git.kaiwu.me - haproxy.git/commitdiff
REGTESTS: sample_fetches: do not race with the server close in proxy_state
authorWilly Tarreau <w@1wt.eu>
Tue, 22 Sep 2026 21:15:20 +0000 (21:15 +0000)
committerWilly Tarreau <w@1wt.eu>
Wed, 30 Sep 2026 15:25:37 +0000 (17:25 +0200)
A full run of the suite caught srv_conn() reporting zero where the test
expects one. The server closed its connection as soon as it had
answered, and when that close reached haproxy before the response rules
were evaluated, the server connection was already released and the
counter had gone back to zero.

The server now holds its connection until the client has read the
response, which is necessarily after the rules have run.

reg-tests/sample_fetches/proxy_state.vtc

index 023176be2cfcc467d1fcd2f47a769fbbe95c6bff..61e11b6c0954336a27e698554eb4d165d4fa50b5 100644 (file)
@@ -9,12 +9,20 @@ varnishtest "Test the proxy and server state sample fetches"
 # A single thread is used because act_conn and fe_conn are over-counted
 # when several threads accept in parallel on a loaded machine, which
 # would make the connection counters below unpredictable.
+#
+# The server holds its connection until the client has read the response
+# because srv_conn() counts the established connections: if the server
+# closed as soon as it answered, its connection could be released before
+# the response rules run and the counter would be read as zero.
 
 feature ignore_unknown_macro
 
+barrier b1 cond 2
+
 server s1 {
        rxreq
        txresp
+       barrier b1 sync
 } -start
 
 haproxy h1 -conf {
@@ -105,6 +113,7 @@ haproxy h1 -conf {
 client c1 -connect ${h1_fe_sock} {
        txreq
        rxresp
+       barrier b1 sync
        expect resp.status == 200
 
        expect resp.http.x-feid       == "11"