r4356 - in trunk/varnish-cache: bin/varnishd bin/varnishtest/tests include lib/libvcl

phk at projects.linpro.no phk at projects.linpro.no
Thu Nov 19 12:40:23 CET 2009


Author: phk
Date: 2009-11-19 12:40:23 +0100 (Thu, 19 Nov 2009)
New Revision: 4356

Modified:
   trunk/varnish-cache/bin/varnishd/cache_backend_poll.c
   trunk/varnish-cache/bin/varnishd/cache_backend_poll.h
   trunk/varnish-cache/bin/varnishtest/tests/v00002.vtc
   trunk/varnish-cache/bin/varnishtest/tests/v00005.vtc
   trunk/varnish-cache/include/vrt.h
   trunk/varnish-cache/lib/libvcl/vcc_backend.c
   trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
   trunk/varnish-cache/lib/libvcl/vcc_obj.c
Log:
Don't halfclose the backend polling TCP connection after sending the
request, some backends gets confused by this.

Add a ".status" to backend polling, to configure the expected HTTP
status code for a good poll.

Fixes #584



Modified: trunk/varnish-cache/bin/varnishd/cache_backend_poll.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_poll.c	2009-11-18 19:54:32 UTC (rev 4355)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_poll.c	2009-11-19 11:40:23 UTC (rev 4356)
@@ -174,23 +174,6 @@
 	}
 	vt->good_xmit |= 1;
 
-	/* And do a shutdown(WR) so we know that the backend got it */
-	i = shutdown(s, SHUT_WR);
-	if (i != 0) {
-		vt->err_shut |= 1;
-		TCP_close(&s);
-		return;
-	}
-	vt->good_shut |= 1;
-
-	/* Check if that took too long time */
-	t_now = TIM_real();
-	tmo = (int)round((t_end - t_now) * 1e3);
-	if (tmo < 0) {
-		TCP_close(&s);
-		return;
-	}
-
 	pfd->fd = s;
 	rlen = 0;
 	do {
@@ -237,7 +220,7 @@
 
 	i = sscanf(vt->resp_buf, "HTTP/%*f %u %s", &resp, buf);
 
-	if (i == 2 && resp == 200)
+	if (i == 2 && resp == vt->probe.exp_status)
 		vt->happy |= 1;
 }
 
@@ -336,6 +319,8 @@
 		vt->probe.window = 8;
 	if (vt->probe.threshold == 0)
 		vt->probe.threshold = 3;
+	if (vt->probe.exp_status == 0)
+		vt->probe.exp_status = 200;
 
 	if (vt->probe.threshold == ~0U)
 		vt->probe.initial = vt->probe.threshold - 1;

Modified: trunk/varnish-cache/bin/varnishd/cache_backend_poll.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_poll.h	2009-11-18 19:54:32 UTC (rev 4355)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_poll.h	2009-11-19 11:40:23 UTC (rev 4356)
@@ -33,8 +33,6 @@
 BITMAP(good_ipv6, '6', "Good IPv6", 0)
 BITMAP( err_xmit, 'x', "Error Xmit", 0)
 BITMAP(good_xmit, 'X', "Good Xmit", 0)
-BITMAP( err_shut, 's', "Error Shut", 0)
-BITMAP(good_shut, 'S', "Good Shut", 0)
 BITMAP( err_recv, 'r', "Error Recv", 0)
 BITMAP(good_recv, 'R', "Good Recv", 0)
 BITMAP(happy,     'H', "Happy", 1)

Modified: trunk/varnish-cache/bin/varnishtest/tests/v00002.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/v00002.vtc	2009-11-18 19:54:32 UTC (rev 4355)
+++ trunk/varnish-cache/bin/varnishtest/tests/v00002.vtc	2009-11-19 11:40:23 UTC (rev 4356)
@@ -185,3 +185,11 @@
 	}
 }
 
+
+varnish v1 -badvcl {
+	backend b1 {
+		.host = "127.0.0.1";
+		.probe = { .status = 13; }
+	}
+}
+

Modified: trunk/varnish-cache/bin/varnishtest/tests/v00005.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/v00005.vtc	2009-11-18 19:54:32 UTC (rev 4355)
+++ trunk/varnish-cache/bin/varnishtest/tests/v00005.vtc	2009-11-19 11:40:23 UTC (rev 4356)
@@ -2,6 +2,16 @@
 
 test "VCL: test backend probe syntax"
 
+# Check status definition
+varnish v1 -vcl {
+	backend b1 {
+		.host = "127.0.0.1";
+		.probe = {
+			.status = 204;
+		}
+	}
+}
+
 # Check url definition
 varnish v1 -vcl {
 	backend b1 {

Modified: trunk/varnish-cache/include/vrt.h
===================================================================
--- trunk/varnish-cache/include/vrt.h	2009-11-18 19:54:32 UTC (rev 4355)
+++ trunk/varnish-cache/include/vrt.h	2009-11-19 11:40:23 UTC (rev 4356)
@@ -52,6 +52,7 @@
 	const char	*request;
 	double		timeout;
 	double		interval;
+	unsigned	exp_status;
 	unsigned	window;
 	unsigned	threshold;
 	unsigned	initial;

Modified: trunk/varnish-cache/lib/libvcl/vcc_backend.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_backend.c	2009-11-18 19:54:32 UTC (rev 4355)
+++ trunk/varnish-cache/lib/libvcl/vcc_backend.c	2009-11-19 11:40:23 UTC (rev 4356)
@@ -343,11 +343,12 @@
 	struct token *t_field;
 	struct token *t_did = NULL, *t_window = NULL, *t_threshold = NULL;
 	struct token *t_initial = NULL;
-	unsigned window, threshold, initial;
+	unsigned window, threshold, initial, status;
 
 	fs = vcc_FldSpec(tl,
 	    "?url",
 	    "?request",
+	    "?status",
 	    "?timeout",
 	    "?interval",
 	    "?window",
@@ -361,6 +362,7 @@
 	window = 0;
 	threshold = 0;
 	initial = 0;
+	status = 0;
 	Fb(tl, 0, "\t.probe = {\n");
 	while (tl->t->tok != '}') {
 
@@ -406,6 +408,17 @@
 			initial = vcc_UintVal(tl);
 			vcc_NextToken(tl);
 			ERRCHK(tl);
+		} else if (vcc_IdIs(t_field, "status")) {
+			status = vcc_UintVal(tl);
+			if (status < 100 || status > 999) {
+				vsb_printf(tl->sb,
+				    "Must specify .status with exactly three "
+				    " digits (100 <= x <= 999)\n");
+				vcc_ErrWhere(tl, tl->t);
+				return;
+			}
+			vcc_NextToken(tl);
+			ERRCHK(tl);
 		} else if (vcc_IdIs(t_field, "threshold")) {
 			t_threshold = tl->t;
 			threshold = vcc_UintVal(tl);
@@ -457,6 +470,8 @@
 		Fb(tl, 0, "\t\t.initial = %u,\n", initial);
 	else
 		Fb(tl, 0, "\t\t.initial = ~0U,\n", initial);
+	if (status > 0)
+		Fb(tl, 0, "\t\t.exp_status = %u,\n", status);
 	Fb(tl, 0, "\t},\n");
 	ExpectErr(tl, '}');
 	vcc_NextToken(tl);

Modified: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c	2009-11-18 19:54:32 UTC (rev 4355)
+++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c	2009-11-19 11:40:23 UTC (rev 4356)
@@ -1,5 +1,5 @@
 /*
- * $Id$
+ * $Id: vcc_gen_fixed_token.tcl 4236 2009-09-14 08:47:03Z phk $
  *
  * NB:  This file is machine generated, DO NOT EDIT!
  *
@@ -159,9 +159,10 @@
 
 	/* ../../include/vcl.h */
 
-	vsb_cat(sb, "/*\n * $Id$\n *\n * NB:  This file is machine generate");
-	vsb_cat(sb, "d, DO NOT EDIT!\n *\n * Edit and run vcc_gen_fixed_tok");
-	vsb_cat(sb, "en.tcl instead\n */\n\nstruct sess;\n");
+	vsb_cat(sb, "/*\n * $Id: vcc_gen_fixed_token.tcl 4236 2009-09-14 08");
+	vsb_cat(sb, ":47:03Z phk $\n *\n * NB:  This file is machine genera");
+	vsb_cat(sb, "ted, DO NOT EDIT!\n *\n * Edit and run vcc_gen_fixed_t");
+	vsb_cat(sb, "oken.tcl instead\n */\n\nstruct sess;\n");
 	vsb_cat(sb, "struct cli;\n\ntypedef void vcl_init_f(struct cli *);\n");
 	vsb_cat(sb, "typedef void vcl_fini_f(struct cli *);\n");
 	vsb_cat(sb, "typedef int vcl_func_f(struct sess *sp);\n");
@@ -227,25 +228,25 @@
 	vsb_cat(sb, " * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWI");
 	vsb_cat(sb, "SE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFT");
 	vsb_cat(sb, "WARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n");
-	vsb_cat(sb, " * SUCH DAMAGE.\n *\n * $Id$\n *\n");
-	vsb_cat(sb, " * Runtime support for compiled VCL programs.\n");
-	vsb_cat(sb, " *\n * XXX: When this file is changed, lib/libvcl/vcc_");
-	vsb_cat(sb, "gen_fixed_token.tcl\n * XXX: *MUST* be rerun.\n");
-	vsb_cat(sb, " */\n\nstruct sess;\nstruct vsb;\n");
-	vsb_cat(sb, "struct cli;\nstruct director;\n");
-	vsb_cat(sb, "struct VCL_conf;\nstruct sockaddr;\n");
-	vsb_cat(sb, "\n/*\n * A backend probe specification\n");
-	vsb_cat(sb, " */\n\nextern const void * const vrt_magic_string_end;");
-	vsb_cat(sb, "\n\nstruct vrt_backend_probe {\n");
+	vsb_cat(sb, " * SUCH DAMAGE.\n *\n * $Id: vrt.h 4336 2009-10-21 11:");
+	vsb_cat(sb, "36:28Z kristian $\n *\n * Runtime support for compiled");
+	vsb_cat(sb, " VCL programs.\n *\n * XXX: When this file is changed,");
+	vsb_cat(sb, " lib/libvcl/vcc_gen_fixed_token.tcl\n");
+	vsb_cat(sb, " * XXX: *MUST* be rerun.\n */\n");
+	vsb_cat(sb, "\nstruct sess;\nstruct vsb;\nstruct cli;\n");
+	vsb_cat(sb, "struct director;\nstruct VCL_conf;\n");
+	vsb_cat(sb, "struct sockaddr;\n\n/*\n * A backend probe specificati");
+	vsb_cat(sb, "on\n */\n\nextern const void * const vrt_magic_string_");
+	vsb_cat(sb, "end;\n\nstruct vrt_backend_probe {\n");
 	vsb_cat(sb, "\tconst char\t*url;\n\tconst char\t*request;\n");
 	vsb_cat(sb, "\tdouble\t\ttimeout;\n\tdouble\t\tinterval;\n");
-	vsb_cat(sb, "\tunsigned\twindow;\n\tunsigned\tthreshold;\n");
-	vsb_cat(sb, "\tunsigned\tinitial;\n};\n\n/*\n");
-	vsb_cat(sb, " * A backend is a host+port somewhere on the network\n");
-	vsb_cat(sb, " */\nstruct vrt_backend {\n\tconst char\t\t\t*vcl_name");
-	vsb_cat(sb, ";\n\tconst char\t\t\t*ident;\n\n");
-	vsb_cat(sb, "\tconst char\t\t\t*hosthdr;\n\n");
-	vsb_cat(sb, "\tconst unsigned char\t\t*ipv4_sockaddr;\n");
+	vsb_cat(sb, "\tunsigned\texp_status;\n\tunsigned\twindow;\n");
+	vsb_cat(sb, "\tunsigned\tthreshold;\n\tunsigned\tinitial;\n");
+	vsb_cat(sb, "};\n\n/*\n * A backend is a host+port somewhere on the");
+	vsb_cat(sb, " network\n */\nstruct vrt_backend {\n");
+	vsb_cat(sb, "\tconst char\t\t\t*vcl_name;\n\tconst char\t\t\t*ident");
+	vsb_cat(sb, ";\n\n\tconst char\t\t\t*hosthdr;\n");
+	vsb_cat(sb, "\n\tconst unsigned char\t\t*ipv4_sockaddr;\n");
 	vsb_cat(sb, "\tconst unsigned char\t\t*ipv6_sockaddr;\n");
 	vsb_cat(sb, "\n\tdouble\t\t\t\tconnect_timeout;\n");
 	vsb_cat(sb, "\tdouble\t\t\t\tfirst_byte_timeout;\n");
@@ -318,25 +319,26 @@
 
 	/* ../../include/vrt_obj.h */
 
-	vsb_cat(sb, "/*\n * $Id$\n *\n * NB:  This file is machine generate");
-	vsb_cat(sb, "d, DO NOT EDIT!\n *\n * Edit and run vcc_gen_fixed_tok");
-	vsb_cat(sb, "en.tcl instead\n */\n\nstruct sockaddr * VRT_r_client_");
-	vsb_cat(sb, "ip(const struct sess *);\nstruct sockaddr * VRT_r_serv");
-	vsb_cat(sb, "er_ip(struct sess *);\nconst char * VRT_r_server_hostn");
-	vsb_cat(sb, "ame(struct sess *);\nconst char * VRT_r_server_identit");
-	vsb_cat(sb, "y(struct sess *);\nint VRT_r_server_port(struct sess *");
-	vsb_cat(sb, ");\nconst char * VRT_r_req_request(const struct sess *");
-	vsb_cat(sb, ");\nvoid VRT_l_req_request(const struct sess *, const ");
-	vsb_cat(sb, "char *, ...);\nconst char * VRT_r_req_url(const struct");
-	vsb_cat(sb, " sess *);\nvoid VRT_l_req_url(const struct sess *, con");
-	vsb_cat(sb, "st char *, ...);\nconst char * VRT_r_req_proto(const s");
-	vsb_cat(sb, "truct sess *);\nvoid VRT_l_req_proto(const struct sess");
-	vsb_cat(sb, " *, const char *, ...);\nvoid VRT_l_req_hash(struct se");
-	vsb_cat(sb, "ss *, const char *);\nstruct director * VRT_r_req_back");
-	vsb_cat(sb, "end(struct sess *);\nvoid VRT_l_req_backend(struct ses");
-	vsb_cat(sb, "s *, struct director *);\nint VRT_r_req_restarts(const");
-	vsb_cat(sb, " struct sess *);\ndouble VRT_r_req_grace(struct sess *");
-	vsb_cat(sb, ");\nvoid VRT_l_req_grace(struct sess *, double);\n");
+	vsb_cat(sb, "/*\n * $Id: vcc_gen_fixed_token.tcl 4236 2009-09-14 08");
+	vsb_cat(sb, ":47:03Z phk $\n *\n * NB:  This file is machine genera");
+	vsb_cat(sb, "ted, DO NOT EDIT!\n *\n * Edit and run vcc_gen_fixed_t");
+	vsb_cat(sb, "oken.tcl instead\n */\n\nstruct sockaddr * VRT_r_clien");
+	vsb_cat(sb, "t_ip(const struct sess *);\nstruct sockaddr * VRT_r_se");
+	vsb_cat(sb, "rver_ip(struct sess *);\nconst char * VRT_r_server_hos");
+	vsb_cat(sb, "tname(struct sess *);\nconst char * VRT_r_server_ident");
+	vsb_cat(sb, "ity(struct sess *);\nint VRT_r_server_port(struct sess");
+	vsb_cat(sb, " *);\nconst char * VRT_r_req_request(const struct sess");
+	vsb_cat(sb, " *);\nvoid VRT_l_req_request(const struct sess *, cons");
+	vsb_cat(sb, "t char *, ...);\nconst char * VRT_r_req_url(const stru");
+	vsb_cat(sb, "ct sess *);\nvoid VRT_l_req_url(const struct sess *, c");
+	vsb_cat(sb, "onst char *, ...);\nconst char * VRT_r_req_proto(const");
+	vsb_cat(sb, " struct sess *);\nvoid VRT_l_req_proto(const struct se");
+	vsb_cat(sb, "ss *, const char *, ...);\nvoid VRT_l_req_hash(struct ");
+	vsb_cat(sb, "sess *, const char *);\nstruct director * VRT_r_req_ba");
+	vsb_cat(sb, "ckend(struct sess *);\nvoid VRT_l_req_backend(struct s");
+	vsb_cat(sb, "ess *, struct director *);\nint VRT_r_req_restarts(con");
+	vsb_cat(sb, "st struct sess *);\ndouble VRT_r_req_grace(struct sess");
+	vsb_cat(sb, " *);\nvoid VRT_l_req_grace(struct sess *, double);\n");
 	vsb_cat(sb, "const char * VRT_r_req_xid(struct sess *);\n");
 	vsb_cat(sb, "unsigned VRT_r_req_esi(struct sess *);\n");
 	vsb_cat(sb, "void VRT_l_req_esi(struct sess *, unsigned);\n");

Modified: trunk/varnish-cache/lib/libvcl/vcc_obj.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_obj.c	2009-11-18 19:54:32 UTC (rev 4355)
+++ trunk/varnish-cache/lib/libvcl/vcc_obj.c	2009-11-19 11:40:23 UTC (rev 4356)
@@ -1,5 +1,5 @@
 /*
- * $Id$
+ * $Id: vcc_gen_fixed_token.tcl 4236 2009-09-14 08:47:03Z phk $
  *
  * NB:  This file is machine generated, DO NOT EDIT!
  *



More information about the varnish-commit mailing list