[6.0] d6fedac35 http2_send: Explain the winup-open discrepancy

Simon Stridsberg simon.stridsberg at varnish-software.com
Mon Mar 18 18:20:06 UTC 2024


commit d6fedac352a618123d3bd75c57528da16d8ff6c7
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Mon Jan 29 10:59:22 2024 +0100

    http2_send: Explain the winup-open discrepancy

diff --git a/bin/varnishd/http2/cache_http2_send.c b/bin/varnishd/http2/cache_http2_send.c
index ca6151fb2..c1e03a5dc 100644
--- a/bin/varnishd/http2/cache_http2_send.c
+++ b/bin/varnishd/http2/cache_http2_send.c
@@ -286,6 +286,18 @@ h2_do_window(struct worker *wrk, struct h2_req *r2,
 			assert (w > 0);
 		}
 
+		/* If all streams ran out of control flow window credits
+		 * upon triggering h2_window_timeout, declare bankruptcy
+		 * for the entire connection.
+		 *
+		 * But streams may be closed from the h2_sess thread while
+		 * waiting for a window update. So the open_streams counter
+		 * may be decremented in a different critical section than
+		 * winup_streams, right before signalling the stream thread.
+		 * So there may be more streams awaiting a window updates
+		 * than streams officially open, hence the "lower-equal"
+		 * comparison.
+		 */
 		if (r2->error == H2SE_BROKE_WINDOW &&
 		    h2->open_streams <= h2->winup_streams)
 			h2->error = r2->error = H2CE_BANKRUPT;


More information about the varnish-commit mailing list