[master] 4e7d66338 vbe: Update the poll timeout before polling-reading in backend probes

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Mon Sep 7 14:56:06 UTC 2020

commit 4e7d663383393c73241fda56189879448e1dfc54
Author: delthas <delthas at dille.cc>
Date:   Mon Sep 7 11:48:49 2020 +0200

    vbe: Update the poll timeout before polling-reading in backend probes
    Varnish uses a global per-probe timeout for backend probes. When reading
    the backend response, Varnish tries to poll and read in a loop, until a
    poll timeouts, the streams EOFs or there is an error.
    The poll is supposed to timeout when the per-probe timeout ends. This is
    currently setup so that `t_end` is the deadline for the probe, set when
    the function starts, then the poll waits until `t_end`.
    Previously, the poll timeout was never updated, and was always set to
    `t_end - t_now` without updating `t_now`, which means that it was
    effectively a between-bytes timeout instead of a proper per-probe
    This fixes this issue by updating `t_now` before updating the
    `t_end - t_now` timeout so that the timeout passed to poll effectively
    corresponds to a deadline of `t_end`.
    See the issue fixed by this commit for more details.
    Fixes: #3402

diff --git a/bin/varnishd/cache/cache_backend_probe.c b/bin/varnishd/cache/cache_backend_probe.c
index 020ee1e75..bf41b952a 100644
--- a/bin/varnishd/cache/cache_backend_probe.c
+++ b/bin/varnishd/cache/cache_backend_probe.c
@@ -348,6 +348,7 @@ vbp_poke(struct vbp_target *vt)
 	while (1) {
 		pfd->events = POLLIN;
 		pfd->revents = 0;
+		t_now = VTIM_real();
 		tmo = (int)round((t_end - t_now) * 1e3);
 		if (tmo <= 0) {

More information about the varnish-commit mailing list