[master] 4e5c8ab Fail gracefully if we can't get a backend on pipe

Federico G. Schwindt fgsch at lodoss.net
Mon May 4 22:20:12 CEST 2015


commit 4e5c8ab06ee081aca68dc04ea91493778ae2a040
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date:   Mon May 4 20:39:23 2015 +0100

    Fail gracefully if we can't get a backend on pipe
    
    Fixes #1730

diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index 114ab38..c555e05 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -277,6 +277,10 @@ vbe_dir_http1pipe(const struct director *d, struct req *req, struct busyobj *bo)
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 
 	i = vbe_dir_getfd(d, bo);
+	if (i < 0) {
+		VSLb(bo->vsl, SLT_FetchError, "no backend connection");
+		return;
+	}
 	V1P_Process(req, bo, i);
 	vbe_dir_finish(d, bo->wrk, bo);
 }
diff --git a/bin/varnishtest/tests/r01730.vtc b/bin/varnishtest/tests/r01730.vtc
new file mode 100644
index 0000000..d19b479
--- /dev/null
+++ b/bin/varnishtest/tests/r01730.vtc
@@ -0,0 +1,15 @@
+varnishtest "Test connection error on pipe"
+
+varnish v1 -vcl {
+       backend default { .host = "${bad_ip}"; }
+       sub vcl_recv {
+               return (pipe);
+       }
+} -start
+
+client c1 {
+       txreq
+       expect_close
+} -run
+
+varnish v1 -expect sc_rx_timeout == 1



More information about the varnish-commit mailing list