[master] 2776433e6 Use `timeout_idle` as a timeout for request body

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Mon Aug 30 08:31:07 UTC 2021


commit 2776433e682f396cf07f9022e5176b82d162ca32
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Tue Jun 22 11:49:28 2021 +0200

    Use `timeout_idle` as a timeout for request body
    
    H2 streams waiting for request body data will timeout after timeout_idle
    seconds if no new data on the stream is being received. This will ensure
    that individual H2 streams can be reaped if there is no data received from
    the peer.

diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c
index 155717fac..570ef9209 100644
--- a/bin/varnishd/http2/cache_http2_proto.c
+++ b/bin/varnishd/http2/cache_http2_proto.c
@@ -33,6 +33,7 @@
 
 #include "cache/cache_varnishd.h"
 
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -946,6 +947,7 @@ h2_vfp_body(struct vfp_ctx *vc, struct vfp_entry *vfe, void *ptr, ssize_t *lp)
 	uint64_t l, l2, tail;
 	uint8_t *dst;
 	char buf[4];
+	int i;
 
 	CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC);
 	CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC);
@@ -980,8 +982,12 @@ h2_vfp_body(struct vfp_ctx *vc, struct vfp_entry *vfe, void *ptr, ssize_t *lp)
 		if (retval != VFP_OK || l > 0)
 			break;
 
-		/* XXX: Timeout */
-		AZ(Lck_CondWait(r2->cond, &h2->sess->mtx, 0));
+		i = Lck_CondWait(r2->cond, &h2->sess->mtx,
+		    VTIM_real() + SESS_TMO(h2->sess, timeout_idle));
+		if (i == ETIMEDOUT) {
+			retval = VFP_ERROR;
+			break;
+		}
 	}
 	r2->cond = NULL;
 


More information about the varnish-commit mailing list