[7.3] 1e6341e51 http2_send: Explain the winup-open discrepancy

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


commit 1e6341e514bc613970360c47c8ef3325e4b6a0e0
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 3a68ad6d5..add519f57 100644
--- a/bin/varnishd/http2/cache_http2_send.c
+++ b/bin/varnishd/http2/cache_http2_send.c
@@ -285,6 +285,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