[master] 19e37f8e1 Rework backend probe code a bit

Federico G. Schwindt fgsch at lodoss.net
Sun Dec 30 18:39:05 UTC 2018


commit 19e37f8e1d8a9220c1cc1e0dc19d6346a622a907
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date:   Sun Dec 30 18:34:40 2018 +0000

    Rework backend probe code a bit
    
    If we timed out during polling display the correct error.  In
    addition, treat all polling errors as receive errors.
    
    Fixes #2866.

diff --git a/bin/varnishd/cache/cache_backend_probe.c b/bin/varnishd/cache/cache_backend_probe.c
index 1537c9de7..3f478db38 100644
--- a/bin/varnishd/cache/cache_backend_probe.c
+++ b/bin/varnishd/cache/cache_backend_probe.c
@@ -341,6 +341,7 @@ vbp_poke(struct vbp_target *vt)
 	/* Send the request */
 	if (vbp_write(vt, &s, vt->req, vt->req_len) != 0)
 		return;
+
 	vt->good_xmit |= 1;
 
 	pfd->fd = s;
@@ -349,21 +350,21 @@ vbp_poke(struct vbp_target *vt)
 		pfd->events = POLLIN;
 		pfd->revents = 0;
 		tmo = (int)round((t_end - t_now) * 1e3);
-		if (tmo > 0)
-			i = poll(pfd, 1, tmo);
-		if (i == 0) {
-			vt->err_recv |= 1;
-			bprintf(vt->resp_buf, "Poll error %d (%s)",
-				errno, vstrerror(errno));
-			VTCP_close(&s);
-			return;
-		}
 		if (tmo <= 0) {
 			bprintf(vt->resp_buf,
-				"Poll (read) timeout %.3fs exceeded by %.3fs",
-				vt->timeout, t_now - t_end);
-			VTCP_close(&s);
-			return;
+			    "Poll timeout %.3fs exceeded by %.3fs",
+			    vt->timeout, t_now - t_end);
+			i = -1;
+			break;
+		}
+		i = poll(pfd, 1, tmo);
+		if (i <= 0) {
+			if (!i)
+				errno = ETIMEDOUT;
+			bprintf(vt->resp_buf, "Poll error %d (%s)",
+			    errno, vstrerror(errno));
+			i = -1;
+			break;
 		}
 		if (rlen < sizeof vt->resp_buf)
 			i = read(s, vt->resp_buf + rlen,


More information about the varnish-commit mailing list