[6.0] 1b9c650d2 h2: Fix a possible thread leak scenario

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Thu Aug 16 08:53:05 UTC 2018


commit 1b9c650d26f2b0c2ae706fbad9a9f302ebbb1ddc
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 1bba9b332..2361c5e40 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