commit eccb50837d61fcb5a6927eef94c570bd1d03c26d
Author: Dridi Boukelmoune <dridi.boukelmoune@gmail.com>
Date: Thu Nov 16 17:02:35 2023 +0100
http2_send: Promote global BROKE_WINDOW to BANKRUPT
When a stream times out waiting for window credits, and all the other
streams are broke, declare the whole connection bankrupt.
diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c
index b575b0f11..1568e76bc 100644
--- a/bin/varnishd/http2/cache_http2_proto.c
+++ b/bin/varnishd/http2/cache_http2_proto.c
@@ -1360,11 +1360,12 @@ static h2_error
h2_sweep(struct worker *wrk, struct h2_sess *h2)
{
struct h2_req *r2, *r22;
- h2_error h2e = NULL, tmo;
+ h2_error h2e, tmo;
vtim_real now;
ASSERT_RXTHR(h2);
+ h2e = h2->error;
now = VTIM_real();
if (h2e == NULL && h2->open_streams == 0 &&
h2->sess->t_idle + cache_param->timeout_idle < now)
diff --git a/bin/varnishd/http2/cache_http2_send.c b/bin/varnishd/http2/cache_http2_send.c
index 0d6b3a6e7..316d13dc5 100644
--- a/bin/varnishd/http2/cache_http2_send.c
+++ b/bin/varnishd/http2/cache_http2_send.c
@@ -285,6 +285,10 @@ h2_do_window(struct worker *wrk, struct h2_req *r2,
assert (w > 0);
}
+ if (r2->error == H2SE_BROKE_WINDOW &&
+ h2->open_streams <= h2->winup_streams)
+ h2->error = r2->error = H2CE_BANKRUPT;
+
assert(h2->winup_streams > 0);
h2->winup_streams--;
diff --git a/bin/varnishtest/tests/t02016.vtc b/bin/varnishtest/tests/t02016.vtc
index d2f5dcca8..1e5a7dc8a 100644
--- a/bin/varnishtest/tests/t02016.vtc
+++ b/bin/varnishtest/tests/t02016.vtc
@@ -6,7 +6,13 @@ server s1 {
} -start
varnish v1 -cliok "param.set feature +http2"
-varnish v1 -vcl+backend "" -start
+varnish v1 -vcl+backend {
+ sub vcl_recv {
+ if (req.url ~ "synth") {
+ return (synth(200));
+ }
+ }
+} -start
# coverage for send_timeout with c1
@@ -66,6 +72,10 @@ client c2 {
} -run
stream 1 {
+ txreq -nostrend -url "/synth"
+ } -run
+
+ stream 3 {
txreq
rxhdrs
rxdata
@@ -75,6 +85,9 @@ client c2 {
expect rst.err == CANCEL
} -run
+ stream 1 {
+ txdata
+ } -run
} -run
logexpect l2 -wait
@@ -100,6 +113,10 @@ client c3 {
} -run
stream 1 {
+ txreq -nostrend -url "/synth"
+ } -run
+
+ stream 3 {
txreq
rxhdrs
rxdata
@@ -110,6 +127,9 @@ client c3 {
expect rst.err == CANCEL
} -run
+ stream 1 {
+ txdata
+ } -run
} -start
barrier b3 sync
diff --git a/include/tbl/h2_error.h b/include/tbl/h2_error.h
index 045ddaa59..564d78544 100644
--- a/include/tbl/h2_error.h
+++ b/include/tbl/h2_error.h
@@ -171,6 +171,14 @@ H2_ERROR(
/* reason */ SC_NULL,
/* descr */ "http/2 stream out of window credits"
)
+
+H2_ERROR(
+ /* name */ BANKRUPT,
+ /* val */ 11, /* ENHANCE_YOUR_CALM */
+ /* types */ 1,
+ /* reason */ SC_BANKRUPT,
+ /* descr */ "http/2 bankrupt connection"
+)
# undef H2_CUSTOM_ERRORS
#endif
_______________________________________________
varnish-commit mailing list
varnish-commit@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit
Author: Dridi Boukelmoune <dridi.boukelmoune@gmail.com>
Date: Thu Nov 16 17:02:35 2023 +0100
http2_send: Promote global BROKE_WINDOW to BANKRUPT
When a stream times out waiting for window credits, and all the other
streams are broke, declare the whole connection bankrupt.
diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c
index b575b0f11..1568e76bc 100644
--- a/bin/varnishd/http2/cache_http2_proto.c
+++ b/bin/varnishd/http2/cache_http2_proto.c
@@ -1360,11 +1360,12 @@ static h2_error
h2_sweep(struct worker *wrk, struct h2_sess *h2)
{
struct h2_req *r2, *r22;
- h2_error h2e = NULL, tmo;
+ h2_error h2e, tmo;
vtim_real now;
ASSERT_RXTHR(h2);
+ h2e = h2->error;
now = VTIM_real();
if (h2e == NULL && h2->open_streams == 0 &&
h2->sess->t_idle + cache_param->timeout_idle < now)
diff --git a/bin/varnishd/http2/cache_http2_send.c b/bin/varnishd/http2/cache_http2_send.c
index 0d6b3a6e7..316d13dc5 100644
--- a/bin/varnishd/http2/cache_http2_send.c
+++ b/bin/varnishd/http2/cache_http2_send.c
@@ -285,6 +285,10 @@ h2_do_window(struct worker *wrk, struct h2_req *r2,
assert (w > 0);
}
+ if (r2->error == H2SE_BROKE_WINDOW &&
+ h2->open_streams <= h2->winup_streams)
+ h2->error = r2->error = H2CE_BANKRUPT;
+
assert(h2->winup_streams > 0);
h2->winup_streams--;
diff --git a/bin/varnishtest/tests/t02016.vtc b/bin/varnishtest/tests/t02016.vtc
index d2f5dcca8..1e5a7dc8a 100644
--- a/bin/varnishtest/tests/t02016.vtc
+++ b/bin/varnishtest/tests/t02016.vtc
@@ -6,7 +6,13 @@ server s1 {
} -start
varnish v1 -cliok "param.set feature +http2"
-varnish v1 -vcl+backend "" -start
+varnish v1 -vcl+backend {
+ sub vcl_recv {
+ if (req.url ~ "synth") {
+ return (synth(200));
+ }
+ }
+} -start
# coverage for send_timeout with c1
@@ -66,6 +72,10 @@ client c2 {
} -run
stream 1 {
+ txreq -nostrend -url "/synth"
+ } -run
+
+ stream 3 {
txreq
rxhdrs
rxdata
@@ -75,6 +85,9 @@ client c2 {
expect rst.err == CANCEL
} -run
+ stream 1 {
+ txdata
+ } -run
} -run
logexpect l2 -wait
@@ -100,6 +113,10 @@ client c3 {
} -run
stream 1 {
+ txreq -nostrend -url "/synth"
+ } -run
+
+ stream 3 {
txreq
rxhdrs
rxdata
@@ -110,6 +127,9 @@ client c3 {
expect rst.err == CANCEL
} -run
+ stream 1 {
+ txdata
+ } -run
} -start
barrier b3 sync
diff --git a/include/tbl/h2_error.h b/include/tbl/h2_error.h
index 045ddaa59..564d78544 100644
--- a/include/tbl/h2_error.h
+++ b/include/tbl/h2_error.h
@@ -171,6 +171,14 @@ H2_ERROR(
/* reason */ SC_NULL,
/* descr */ "http/2 stream out of window credits"
)
+
+H2_ERROR(
+ /* name */ BANKRUPT,
+ /* val */ 11, /* ENHANCE_YOUR_CALM */
+ /* types */ 1,
+ /* reason */ SC_BANKRUPT,
+ /* descr */ "http/2 bankrupt connection"
+)
# undef H2_CUSTOM_ERRORS
#endif
_______________________________________________
varnish-commit mailing list
varnish-commit@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit