[master] 1ff0c0f4e vrt_var: Make bereq.task_deadline unset-able

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Mon Feb 5 10:54:05 UTC 2024


commit 1ff0c0f4eefbd6392c89e7b04a775c1daf9f62b5
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Mon Feb 5 11:36:11 2024 +0100

    vrt_var: Make bereq.task_deadline unset-able
    
    The other timeouts should eventually become unset-able as well, where
    an unset variable falls back to a parameter and zero means no timeout,
    overriding the fallback parameter.
    
    Refs #4043

diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index b69005cd0..9a14519b8 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -387,7 +387,19 @@ VRT_l_client_identity(VRT_CTX, const char *str, VCL_STRANDS s)
 
 /*--------------------------------------------------------------------*/
 
-#define BEREQ_TIMEOUT(which)					\
+#define BEREQ_TIMEOUT_UNSET0(which)
+
+#define BEREQ_TIMEOUT_UNSET1(which)				\
+VCL_VOID							\
+VRT_u_bereq_##which(VRT_CTX)					\
+{								\
+								\
+	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);			\
+	CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC);		\
+	ctx->bo->which = NAN;					\
+}
+
+#define BEREQ_TIMEOUT(which, unset)				\
 VCL_VOID							\
 VRT_l_bereq_##which(VRT_CTX, VCL_DURATION num)			\
 {								\
@@ -404,12 +416,14 @@ VRT_r_bereq_##which(VRT_CTX)					\
 	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);			\
 	CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC);		\
 	return (ctx->bo->which);				\
-}
+}								\
+								\
+BEREQ_TIMEOUT_UNSET##unset(which)
 
-BEREQ_TIMEOUT(connect_timeout)
-BEREQ_TIMEOUT(first_byte_timeout)
-BEREQ_TIMEOUT(between_bytes_timeout)
-BEREQ_TIMEOUT(task_deadline)
+BEREQ_TIMEOUT(connect_timeout, 0)
+BEREQ_TIMEOUT(first_byte_timeout, 0)
+BEREQ_TIMEOUT(between_bytes_timeout, 0)
+BEREQ_TIMEOUT(task_deadline, 1)
 
 
 /*--------------------------------------------------------------------*/
diff --git a/bin/varnishtest/tests/s00013.vtc b/bin/varnishtest/tests/s00013.vtc
index 2898ec87f..46c7844ba 100644
--- a/bin/varnishtest/tests/s00013.vtc
+++ b/bin/varnishtest/tests/s00013.vtc
@@ -27,8 +27,9 @@ varnish v1 -cliok "param.set pipe_timeout 0s"
 varnish v1 -cliok "param.set pipe_task_deadline 0s"
 varnish v1 -vcl+backend {
 	sub vcl_pipe {
-		if (req.method == "TMO") {
-			set bereq.task_deadline = 1.1s;
+		set bereq.task_deadline = 1.1s;
+		if (req.method != "TMO") {
+			unset bereq.task_deadline;
 		}
 	}
 } -start
diff --git a/doc/sphinx/reference/vcl_var.rst b/doc/sphinx/reference/vcl_var.rst
index 510d13950..16bb9c8c7 100644
--- a/doc/sphinx/reference/vcl_var.rst
+++ b/doc/sphinx/reference/vcl_var.rst
@@ -850,8 +850,10 @@ bereq.task_deadline
 
 	Writable from: vcl_pipe
 
+	Unsetable from: vcl_pipe
+
 	Deadline for pipe sessions, defaults ``0s``, which falls back to the
-        ``pipe_task_deadline`` parameter, see :ref:`varnishd(1)`
+	``pipe_task_deadline`` parameter, see :ref:`varnishd(1)`
 
 
 .. _bereq.time:


More information about the varnish-commit mailing list