[6.0] ba32ab35b Use `timeout_idle` as a timeout for request body

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Wed Oct 18 09:21:07 UTC 2023


commit ba32ab35b9e4eea78c2bdeefd95bc5d5e7cf8084
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 bdd5eeec6..6bb7a9ad6 100644
--- a/bin/varnishd/http2/cache_http2_proto.c
+++ b/bin/varnishd/http2/cache_http2_proto.c
@@ -31,6 +31,7 @@
 
 #include "cache/cache_varnishd.h"
 
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -955,6 +956,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);
@@ -989,8 +991,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