Skip to content

Commit 1ff0c0f

Browse files
committed
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
1 parent 98945ce commit 1ff0c0f

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

bin/varnishd/cache/cache_vrt_var.c

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,19 @@ VRT_l_client_identity(VRT_CTX, const char *str, VCL_STRANDS s)
387387

388388
/*--------------------------------------------------------------------*/
389389

390-
#define BEREQ_TIMEOUT(which) \
390+
#define BEREQ_TIMEOUT_UNSET0(which)
391+
392+
#define BEREQ_TIMEOUT_UNSET1(which) \
393+
VCL_VOID \
394+
VRT_u_bereq_##which(VRT_CTX) \
395+
{ \
396+
\
397+
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \
398+
CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); \
399+
ctx->bo->which = NAN; \
400+
}
401+
402+
#define BEREQ_TIMEOUT(which, unset) \
391403
VCL_VOID \
392404
VRT_l_bereq_##which(VRT_CTX, VCL_DURATION num) \
393405
{ \
@@ -404,12 +416,14 @@ VRT_r_bereq_##which(VRT_CTX) \
404416
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \
405417
CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); \
406418
return (ctx->bo->which); \
407-
}
419+
} \
420+
\
421+
BEREQ_TIMEOUT_UNSET##unset(which)
408422

409-
BEREQ_TIMEOUT(connect_timeout)
410-
BEREQ_TIMEOUT(first_byte_timeout)
411-
BEREQ_TIMEOUT(between_bytes_timeout)
412-
BEREQ_TIMEOUT(task_deadline)
423+
BEREQ_TIMEOUT(connect_timeout, 0)
424+
BEREQ_TIMEOUT(first_byte_timeout, 0)
425+
BEREQ_TIMEOUT(between_bytes_timeout, 0)
426+
BEREQ_TIMEOUT(task_deadline, 1)
413427

414428

415429
/*--------------------------------------------------------------------*/

bin/varnishtest/tests/s00013.vtc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ varnish v1 -cliok "param.set pipe_timeout 0s"
2727
varnish v1 -cliok "param.set pipe_task_deadline 0s"
2828
varnish v1 -vcl+backend {
2929
sub vcl_pipe {
30-
if (req.method == "TMO") {
31-
set bereq.task_deadline = 1.1s;
30+
set bereq.task_deadline = 1.1s;
31+
if (req.method != "TMO") {
32+
unset bereq.task_deadline;
3233
}
3334
}
3435
} -start

doc/sphinx/reference/vcl_var.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,8 +850,10 @@ bereq.task_deadline
850850

851851
Writable from: vcl_pipe
852852

853+
Unsetable from: vcl_pipe
854+
853855
Deadline for pipe sessions, defaults ``0s``, which falls back to the
854-
``pipe_task_deadline`` parameter, see :ref:`varnishd(1)`
856+
``pipe_task_deadline`` parameter, see :ref:`varnishd(1)`
855857

856858

857859
.. _bereq.time:

0 commit comments

Comments
 (0)