[master] 4b73c5f h2: Fix a possible thread leak scenario
Dag Haavi Finstad
daghf at varnish-software.com
Wed May 30 09:29:20 UTC 2018
commit 4b73c5f75214e4cd41e1a7a039c9219f6ab1168a
Author: Dag Haavi Finstad <daghf at varnish-software.com>
Date: Tue May 29 14:44:16 2018 +0200
h2: Fix a possible thread leak scenario
If we have one or more streams set up because of a PRIORITY frame _and_
for some reason a tcp FIN is lost (or a client merely keeps a connection
open), this transaction would be stalled indefinitely.
diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c
index 1bba9b3..2361c5e 100644
--- a/bin/varnishd/http2/cache_http2_proto.c
+++ b/bin/varnishd/http2/cache_http2_proto.c
@@ -964,6 +964,7 @@ static int
h2_sweep(struct worker *wrk, struct h2_sess *h2)
{
int tmo = 0;
+ int nprio = 0;
struct h2_req *r2, *r22;
ASSERT_RXTHR(h2);
@@ -994,13 +995,21 @@ h2_sweep(struct worker *wrk, struct h2_sess *h2)
continue;
}
break;
+ case H2_S_IDLE:
+ /* This stream was created from receiving a
+ * PRIORITY frame, and should not be counted
+ * as an active stream keeping the connection
+ * open. */
+ AZ(r2->scheduled);
+ nprio++;
+ break;
default:
break;
}
}
if (tmo)
return (0);
- return (h2->refcnt > 1);
+ return ((h2->refcnt - nprio) > 1);
}
More information about the varnish-commit
mailing list