[master] 52b7275 Now that we have more confidence in the gzip-patchworking-code be less draconian about error handling and debugging.
Poul-Henning Kamp
phk at varnish-cache.org
Sun Apr 3 10:28:49 CEST 2011
commit 52b72752155d31efa176b6b738ce3acc488e8f9a
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Sun Apr 3 08:27:23 2011 +0000
Now that we have more confidence in the gzip-patchworking-code be less
draconian about error handling and debugging.
Properly handle two src= attributes in an esi:include tag (ignore
the entire tag, log the error)
Deal with clients which close the connection half-way through an
ESI delivery.
diff --git a/bin/varnishd/cache.h b/bin/varnishd/cache.h
index 337f3ee..4bc7309 100644
--- a/bin/varnishd/cache.h
+++ b/bin/varnishd/cache.h
@@ -693,6 +693,7 @@ int VGZ_WrwGunzip(struct sess *, struct vgz *, void *ibuf, ssize_t ibufl,
char *obuf, ssize_t obufl, ssize_t *obufp);
/* Return values */
+#define VGZ_SOCKET -2
#define VGZ_ERROR -1
#define VGZ_OK 0
#define VGZ_END 1
diff --git a/bin/varnishd/cache_esi_deliver.c b/bin/varnishd/cache_esi_deliver.c
index b666c79..6e82db1 100644
--- a/bin/varnishd/cache_esi_deliver.c
+++ b/bin/varnishd/cache_esi_deliver.c
@@ -59,11 +59,6 @@ ved_include(struct sess *sp, const char *src, const char *host)
return;
sp->esi_level++;
- if (WRW_Flush(w)) {
- vca_close_session(sp, "remote closed");
- return;
- }
-
(void)WRW_FlushRelease(w);
obj = sp->obj;
@@ -335,6 +330,12 @@ ESI_Deliver(struct sess *sp)
i = VGZ_WrwGunzip(sp, vgz,
st->ptr + off, l2,
obuf, sizeof obuf, &obufl);
+ if (i == VGZ_SOCKET) {
+ vca_close_session(sp,
+ "remote closed");
+ p = e;
+ break;
+ }
assert (i == VGZ_OK || i == VGZ_END);
} else {
/*
@@ -382,6 +383,11 @@ ESI_Deliver(struct sess *sp)
WRW_Write(sp->wrk, obuf, obufl);
obufl = 0;
}
+ if (WRW_Flush(sp->wrk)) {
+ vca_close_session(sp, "remote closed");
+ p = e;
+ break;
+ }
Debug("INCL [%s][%s] BEGIN\n", q, p);
ved_include(sp, (const char*)q, (const char*)p);
Debug("INCL [%s][%s] END\n", q, p);
diff --git a/bin/varnishd/cache_esi_parse.c b/bin/varnishd/cache_esi_parse.c
index 48ca71e..dcf6ba7 100644
--- a/bin/varnishd/cache_esi_parse.c
+++ b/bin/varnishd/cache_esi_parse.c
@@ -188,7 +188,6 @@ vep_error(const struct vep_state *vep, const char *p)
VSC_main->esi_errors++;
l = (intmax_t)(vep->ver_p - vep->hack_p);
- printf("ERROR at %jd %s\n", l , p);
WSP(vep->sp, SLT_ESI_xmlerror, "ERR at %jd %s", l, p);
}
@@ -450,6 +449,17 @@ vep_do_include(struct vep_state *vep, enum dowhat what)
if (what == DO_ATTR) {
Debug("ATTR (%s) (%s)\n", vep->match_hit->match,
vsb_data(vep->attr_vsb));
+ if (vep->include_src != NULL) {
+ vep_error(vep,
+ "ESI 1.0 <esi:include> "
+ "has multiple src= attributes");
+ vep->state = VEP_TAGERROR;
+ vsb_delete(vep->attr_vsb);
+ vsb_delete(vep->include_src);
+ vep->attr_vsb = NULL;
+ vep->include_src = NULL;
+ return;
+ }
XXXAZ(vep->include_src); /* multiple src= */
vep->include_src = vep->attr_vsb;
return;
@@ -872,13 +882,13 @@ VEP_parse(const struct sess *sp, const char *p, size_t l)
} else if (p < e) {
vep->attr_delim = 0;
p++;
+ vep->state = VEP_INTAG;
if (vep->attr_vsb != NULL) {
vsb_finish(vep->attr_vsb);
AN(vep->dostuff);
vep->dostuff(vep, DO_ATTR);
vep->attr_vsb = NULL;
}
- vep->state = VEP_INTAG;
}
/******************************************************
diff --git a/bin/varnishd/cache_gzip.c b/bin/varnishd/cache_gzip.c
index b4d78dd..7e389c9 100644
--- a/bin/varnishd/cache_gzip.c
+++ b/bin/varnishd/cache_gzip.c
@@ -383,7 +383,7 @@ VGZ_WrwGunzip(struct sess *sp, struct vgz *vg, void *ibuf, ssize_t ibufl,
if (obufl == *obufp || i == VGZ_STUCK) {
WRW_Write(sp->wrk, obuf, *obufp);
if (WRW_Flush(sp->wrk))
- return (-1);
+ return (VGZ_SOCKET);
*obufp = 0;
VGZ_Obuf(vg, obuf + *obufp, obufl - *obufp);
}
diff --git a/bin/varnishtest/tests/r00894.vtc b/bin/varnishtest/tests/r00894.vtc
new file mode 100644
index 0000000..c22037f
--- /dev/null
+++ b/bin/varnishtest/tests/r00894.vtc
@@ -0,0 +1,20 @@
+# $Id$
+
+test "Ticket #894"
+
+server s1 {
+ rxreq
+ txresp -body {<XXX><esi:include src="a" src="b"/><YYY>}
+} -start
+
+varnish v1 -vcl+backend {
+ sub vcl_fetch {
+ set beresp.do_esi = true;
+ }
+} -start
+
+client c1 {
+ txreq
+ rxresp
+ expect resp.bodylen == 10
+} -run
More information about the varnish-commit
mailing list