r4381 - in branches/2.0/varnish-cache: bin/varnishd bin/varnishtest/tests include lib/libvcl
tfheen at projects.linpro.no
tfheen at projects.linpro.no
Thu Dec 3 12:02:46 CET 2009
Author: tfheen
Date: 2009-12-03 12:02:46 +0100 (Thu, 03 Dec 2009)
New Revision: 4381
Modified:
branches/2.0/varnish-cache/bin/varnishd/cache_backend_poll.c
branches/2.0/varnish-cache/bin/varnishd/cache_backend_poll.h
branches/2.0/varnish-cache/bin/varnishtest/tests/v00002.vtc
branches/2.0/varnish-cache/bin/varnishtest/tests/v00005.vtc
branches/2.0/varnish-cache/include/vrt.h
branches/2.0/varnish-cache/lib/libvcl/vcc_backend.c
branches/2.0/varnish-cache/lib/libvcl/vcc_fixed_token.c
Log:
Merge r4356, r4357: Don't half-close probes, add .expected_response
r4356:
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
r4357:
.expected_response is a better idea than .status
Tip o' the hat to: tfheen
Modified: branches/2.0/varnish-cache/bin/varnishd/cache_backend_poll.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/cache_backend_poll.c 2009-12-03 10:45:09 UTC (rev 4380)
+++ branches/2.0/varnish-cache/bin/varnishd/cache_backend_poll.c 2009-12-03 11:02:46 UTC (rev 4381)
@@ -173,23 +173,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 {
@@ -236,7 +219,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;
}
@@ -335,6 +318,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: branches/2.0/varnish-cache/bin/varnishd/cache_backend_poll.h
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/cache_backend_poll.h 2009-12-03 10:45:09 UTC (rev 4380)
+++ branches/2.0/varnish-cache/bin/varnishd/cache_backend_poll.h 2009-12-03 11:02:46 UTC (rev 4381)
@@ -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: branches/2.0/varnish-cache/bin/varnishtest/tests/v00002.vtc
===================================================================
--- branches/2.0/varnish-cache/bin/varnishtest/tests/v00002.vtc 2009-12-03 10:45:09 UTC (rev 4380)
+++ branches/2.0/varnish-cache/bin/varnishtest/tests/v00002.vtc 2009-12-03 11:02:46 UTC (rev 4381)
@@ -185,3 +185,11 @@
}
}
+
+varnish v1 -badvcl {
+ backend b1 {
+ .host = "127.0.0.1";
+ .probe = { .expected_response = 13; }
+ }
+}
+
Modified: branches/2.0/varnish-cache/bin/varnishtest/tests/v00005.vtc
===================================================================
--- branches/2.0/varnish-cache/bin/varnishtest/tests/v00005.vtc 2009-12-03 10:45:09 UTC (rev 4380)
+++ branches/2.0/varnish-cache/bin/varnishtest/tests/v00005.vtc 2009-12-03 11:02:46 UTC (rev 4381)
@@ -2,6 +2,16 @@
test "VCL: test backend probe syntax"
+# Check status definition
+varnish v1 -vcl {
+ backend b1 {
+ .host = "127.0.0.1";
+ .probe = {
+ .expected_response = 204;
+ }
+ }
+}
+
# Check url definition
varnish v1 -vcl {
backend b1 {
Modified: branches/2.0/varnish-cache/include/vrt.h
===================================================================
--- branches/2.0/varnish-cache/include/vrt.h 2009-12-03 10:45:09 UTC (rev 4380)
+++ branches/2.0/varnish-cache/include/vrt.h 2009-12-03 11:02:46 UTC (rev 4381)
@@ -52,6 +52,7 @@
const char *request;
double timeout;
double interval;
+ unsigned exp_status;
unsigned window;
unsigned threshold;
unsigned initial;
Modified: branches/2.0/varnish-cache/lib/libvcl/vcc_backend.c
===================================================================
--- branches/2.0/varnish-cache/lib/libvcl/vcc_backend.c 2009-12-03 10:45:09 UTC (rev 4380)
+++ branches/2.0/varnish-cache/lib/libvcl/vcc_backend.c 2009-12-03 11:02:46 UTC (rev 4381)
@@ -341,11 +341,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",
+ "?expected_response",
"?timeout",
"?interval",
"?window",
@@ -359,6 +360,7 @@
window = 0;
threshold = 0;
initial = 0;
+ status = 0;
Fb(tl, 0, "\t.probe = {\n");
while (tl->t->tok != '}') {
@@ -404,6 +406,17 @@
initial = vcc_UintVal(tl);
vcc_NextToken(tl);
ERRCHK(tl);
+ } else if (vcc_IdIs(t_field, "expected_response")) {
+ 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);
@@ -455,6 +468,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: branches/2.0/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- branches/2.0/varnish-cache/lib/libvcl/vcc_fixed_token.c 2009-12-03 10:45:09 UTC (rev 4380)
+++ branches/2.0/varnish-cache/lib/libvcl/vcc_fixed_token.c 2009-12-03 11:02:46 UTC (rev 4381)
@@ -246,13 +246,14 @@
vsb_cat(sb, "on\n */\n\nextern void *vrt_magic_string_end;\n");
vsb_cat(sb, "\nstruct vrt_backend_probe {\n\tconst char\t*url;\n");
vsb_cat(sb, "\tconst char\t*request;\n\tdouble\t\ttimeout;\n");
- vsb_cat(sb, "\tdouble\t\tinterval;\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, "\tdouble\t\tinterval;\n\tunsigned\texp_status;\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, "\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");
@@ -324,9 +325,9 @@
/* ../../include/vrt_obj.h */
- vsb_cat(sb, "/*\n * $Id: vcc_gen_obj.tcl 4082 2009-05-19 07:14:00Z ");
- vsb_cat(sb, "sky $\n *\n * NB: This file is machine generated, DO ");
- vsb_cat(sb, "NOT EDIT!\n *\n * Edit vcc_gen_obj.tcl instead\n");
+ vsb_cat(sb, "/*\n * $Id$\n");
+ vsb_cat(sb, " *\n * NB: This file is machine generated, DO NOT EDI");
+ vsb_cat(sb, "T!\n *\n * Edit vcc_gen_obj.tcl instead\n");
vsb_cat(sb, " */\n\nstruct sockaddr * VRT_r_client_ip(const struct ");
vsb_cat(sb, "sess *);\nstruct sockaddr * VRT_r_server_ip(struct ses");
vsb_cat(sb, "s *);\nconst char * VRT_r_server_hostname(struct sess ");
More information about the varnish-commit
mailing list