[6.0] c0dc68441 Fix an h2 reqbody resource leak

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


commit c0dc68441efe89f25a86e12a72392278d5d0826b
Author: Dag Haavi Finstad <daghf at varnish-software.com>
Date:   Wed May 30 11:17:51 2018 +0200

    Fix an h2 reqbody resource leak
    
    Properly shut down streams where we could not process a req
    body (e.g. via a failing cache_req_body). The rxthread may be waiting on
    this stream to consume a DATA frame - let it know before we go away to
    avoid it being stuck forever.

diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c
index dc1212a7d..64d55a6f9 100644
--- a/bin/varnishd/http2/cache_http2_proto.c
+++ b/bin/varnishd/http2/cache_http2_proto.c
@@ -812,9 +812,34 @@ h2_vfp_body(struct vfp_ctx *vc, struct vfp_entry *vfe, void *ptr, ssize_t *lp)
 	return (retval);
 }
 
+static void
+h2_vfp_body_fini(struct vfp_ctx *vc, struct vfp_entry *vfe)
+{
+	struct h2_req *r2;
+	struct h2_sess *h2;
+
+	CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC);
+	CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC);
+	CAST_OBJ_NOTNULL(r2, vfe->priv1, H2_REQ_MAGIC);
+	CHECK_OBJ_NOTNULL(r2->req, REQ_MAGIC);
+	h2 = r2->h2sess;
+
+	if (vc->failed) {
+		CHECK_OBJ_NOTNULL(r2->req->wrk, WORKER_MAGIC);
+		h2_tx_rst(r2->req->wrk, h2, r2, r2->stream,
+		    H2SE_REFUSED_STREAM);
+		Lck_Lock(&h2->sess->mtx);
+		r2->error = H2SE_REFUSED_STREAM;
+		if (h2->mailcall == r2)
+			AZ(pthread_cond_signal(h2->cond));
+		Lck_Unlock(&h2->sess->mtx);
+	}
+}
+
 static const struct vfp h2_body = {
 	.name = "H2_BODY",
 	.pull = h2_vfp_body,
+	.fini = h2_vfp_body_fini
 };
 
 void v_matchproto_(vtr_req_body_t)


More information about the varnish-commit mailing list