r3991 - in branches/2.0/varnish-cache: bin/varnishd bin/varnishtest/tests include lib/libvcl
tfheen at projects.linpro.no
tfheen at projects.linpro.no
Mon Mar 23 13:42:15 CET 2009
Author: tfheen
Date: 2009-03-23 13:42:15 +0100 (Mon, 23 Mar 2009)
New Revision: 3991
Added:
branches/2.0/varnish-cache/bin/varnishtest/tests/c00024.vtc
Modified:
branches/2.0/varnish-cache/bin/varnishd/cache_center.c
branches/2.0/varnish-cache/include/vcl_returns.h
branches/2.0/varnish-cache/lib/libvcl/vcc_fixed_token.c
branches/2.0/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl
Log:
Merge r3948: Allow restart in vcl_error
Modified: branches/2.0/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/cache_center.c 2009-03-23 12:37:42 UTC (rev 3990)
+++ branches/2.0/varnish-cache/bin/varnishd/cache_center.c 2009-03-23 12:42:15 UTC (rev 3991)
@@ -305,10 +305,6 @@
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
AZ(sp->bereq);
- /* We always close when we take this path */
- sp->doclose = "error";
- sp->wantbody = 1;
-
w = sp->wrk;
if (sp->obj == NULL) {
HSH_Prealloc(sp);
@@ -335,6 +331,19 @@
http_PutResponse(w, sp->fd, h,
http_StatusMessage(sp->err_code));
VCL_error_method(sp);
+
+ if (sp->handling == VCL_RET_RESTART) {
+ HSH_Drop(sp);
+ sp->director = NULL;
+ sp->restarts++;
+ sp->step = STP_RECV;
+ return (0);
+ }
+
+ /* We always close when we take this path */
+ sp->doclose = "error";
+ sp->wantbody = 1;
+
assert(sp->handling == VCL_RET_DELIVER);
sp->err_code = 0;
sp->err_reason = NULL;
Copied: branches/2.0/varnish-cache/bin/varnishtest/tests/c00024.vtc (from rev 3948, trunk/varnish-cache/bin/varnishtest/tests/c00024.vtc)
===================================================================
--- branches/2.0/varnish-cache/bin/varnishtest/tests/c00024.vtc (rev 0)
+++ branches/2.0/varnish-cache/bin/varnishtest/tests/c00024.vtc 2009-03-23 12:42:15 UTC (rev 3991)
@@ -0,0 +1,38 @@
+# $Id$
+
+test "Test restart in vcl_error"
+
+server s1 {
+ rxreq
+ txresp
+} -start
+
+varnish v1 -vcl {
+ backend bad {
+ .host = "127.0.0.1";
+ .port = "9099";
+ }
+ backend good {
+ .host = "127.0.0.1";
+ .port = "9080";
+ }
+ sub vcl_recv {
+ if (req.restarts > 0) {
+ set req.backend = good;
+ }
+ }
+ sub vcl_error {
+ if (req.restarts < 1) {
+ restart;
+ } else {
+ set obj.status = 201;
+ }
+ }
+ } -start
+
+client c1 {
+ txreq -url "/"
+ rxresp
+ expect resp.status == 200
+} -run
+
Modified: branches/2.0/varnish-cache/include/vcl_returns.h
===================================================================
--- branches/2.0/varnish-cache/include/vcl_returns.h 2009-03-23 12:37:42 UTC (rev 3990)
+++ branches/2.0/varnish-cache/include/vcl_returns.h 2009-03-23 12:42:15 UTC (rev 3991)
@@ -73,6 +73,7 @@
| (1 << VCL_RET_KEEP)
))
VCL_MET_MAC(error,ERROR,
- ((1 << VCL_RET_DELIVER)
+ ((1 << VCL_RET_RESTART)
+ | (1 << VCL_RET_DELIVER)
))
#endif
Modified: branches/2.0/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- branches/2.0/varnish-cache/lib/libvcl/vcc_fixed_token.c 2009-03-23 12:37:42 UTC (rev 3990)
+++ branches/2.0/varnish-cache/lib/libvcl/vcc_fixed_token.c 2009-03-23 12:42:15 UTC (rev 3991)
@@ -324,9 +324,9 @@
/* ../../include/vrt_obj.h */
- vsb_cat(sb, "/*\n * $Id: vcc_gen_obj.tcl 3616 2009-02-05 11:43:20Z ");
- vsb_cat(sb, "tfheen $\n *\n * NB: This file is machine generated, ");
- vsb_cat(sb, "DO NOT EDIT!\n *\n * Edit vcc_gen_obj.tcl instead\n");
+ vsb_cat(sb, "/*\n * $Id: vrt_obj.h 3990 2009-03-23 12:37:42Z tfheen");
+ vsb_cat(sb, " $\n *\n * NB: This file is machine generated, DO NOT");
+ vsb_cat(sb, " EDIT!\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 ");
Modified: branches/2.0/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl
===================================================================
--- branches/2.0/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl 2009-03-23 12:37:42 UTC (rev 3990)
+++ branches/2.0/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl 2009-03-23 12:42:15 UTC (rev 3991)
@@ -45,7 +45,7 @@
{prefetch {fetch pass}}
{timeout {fetch discard}}
{discard {discard keep}}
- {error {deliver}}
+ {error {restart deliver}}
}
# These are the return actions
More information about the varnish-commit
mailing list