[master] f6baebc Also snapshot the worker thread workspace around esi:include processing.
Poul-Henning Kamp
phk at varnish-cache.org
Tue Oct 25 09:53:13 CEST 2011
commit f6baebcc2931036353356b16662e70de0363a1fe
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Oct 25 07:52:09 2011 +0000
Also snapshot the worker thread workspace around esi:include
processing.
Convert a few http_PrintfHeader() to http_SetHeader() for good
measure: There is no reason to waste workspace on compiled in strings.
Fixes #1038
diff --git a/bin/varnishd/cache_center.c b/bin/varnishd/cache_center.c
index 418fbe9..91ee652 100644
--- a/bin/varnishd/cache_center.c
+++ b/bin/varnishd/cache_center.c
@@ -467,7 +467,7 @@ cnt_error(struct sess *sp)
http_PutStatus(h, sp->err_code);
VTIM_format(VTIM_real(), date);
http_PrintfHeader(w, sp->vsl_id, h, "Date: %s", date);
- http_PrintfHeader(w, sp->vsl_id, h, "Server: Varnish");
+ http_SetHeader(w, sp->vsl_id, h, "Server: Varnish");
if (sp->err_reason != NULL)
http_PutResponse(w, sp->vsl_id, h, sp->err_reason);
@@ -727,8 +727,8 @@ cnt_fetchbody(struct sess *sp)
/* If we do gzip, add the C-E header */
if (sp->wrk->do_gzip)
- http_PrintfHeader(sp->wrk, sp->vsl_id, sp->wrk->beresp,
- "Content-Encoding: %s", "gzip");
+ http_SetHeader(sp->wrk, sp->vsl_id, sp->wrk->beresp,
+ "Content-Encoding: gzip");
/* But we can't do both at the same time */
assert(sp->wrk->do_gzip == 0 || sp->wrk->do_gunzip == 0);
@@ -1193,7 +1193,7 @@ cnt_miss(struct sess *sp)
* the minority of clients which don't.
*/
http_Unset(sp->wrk->bereq, H_Accept_Encoding);
- http_PrintfHeader(sp->wrk, sp->vsl_id, sp->wrk->bereq,
+ http_SetHeader(sp->wrk, sp->vsl_id, sp->wrk->bereq,
"Accept-Encoding: gzip");
}
sp->wrk->connect_timeout = 0;
@@ -1397,7 +1397,7 @@ cnt_recv(struct sess *sp)
(recv_handling != VCL_RET_PASS)) {
if (RFC2616_Req_Gzip(sp)) {
http_Unset(sp->http, H_Accept_Encoding);
- http_PrintfHeader(sp->wrk, sp->vsl_id, sp->http,
+ http_SetHeader(sp->wrk, sp->vsl_id, sp->http,
"Accept-Encoding: gzip");
} else {
http_Unset(sp->http, H_Accept_Encoding);
diff --git a/bin/varnishd/cache_esi_deliver.c b/bin/varnishd/cache_esi_deliver.c
index c79da64..c10452e 100644
--- a/bin/varnishd/cache_esi_deliver.c
+++ b/bin/varnishd/cache_esi_deliver.c
@@ -46,7 +46,8 @@ ved_include(struct sess *sp, const char *src, const char *host)
{
struct object *obj;
struct worker *w;
- char *ws_wm;
+ char *sp_ws_wm;
+ char *wrk_ws_wm;
unsigned sxid, res_mode;
w = sp->wrk;
@@ -65,7 +66,8 @@ ved_include(struct sess *sp, const char *src, const char *host)
HTTP_Copy(sp->http, sp->http0);
/* Take a workspace snapshot */
- ws_wm = WS_Snapshot(sp->ws);
+ sp_ws_wm = WS_Snapshot(sp->ws);
+ wrk_ws_wm = WS_Snapshot(w->ws);
http_SetH(sp->http, HTTP_HDR_URL, src);
if (host != NULL && *host != '\0') {
@@ -115,7 +117,8 @@ ved_include(struct sess *sp, const char *src, const char *host)
sp->wrk->res_mode = res_mode;
/* Reset the workspace */
- WS_Reset(sp->ws, ws_wm);
+ WS_Reset(sp->ws, sp_ws_wm);
+ WS_Reset(w->ws, wrk_ws_wm);
WRW_Reserve(sp->wrk, &sp->fd);
if (sp->wrk->res_mode & RES_CHUNKED)
diff --git a/bin/varnishd/cache_response.c b/bin/varnishd/cache_response.c
index ecc9839..569f24f 100644
--- a/bin/varnishd/cache_response.c
+++ b/bin/varnishd/cache_response.c
@@ -125,7 +125,7 @@ RES_BuildHttp(const struct sess *sp)
}
if (sp->wrk->res_mode & RES_CHUNKED)
- http_PrintfHeader(sp->wrk, sp->vsl_id, sp->wrk->resp,
+ http_SetHeader(sp->wrk, sp->vsl_id, sp->wrk->resp,
"Transfer-Encoding: chunked");
VTIM_format(VTIM_real(), time_str);
diff --git a/bin/varnishtest/tests/r01038.vtc b/bin/varnishtest/tests/r01038.vtc
new file mode 100644
index 0000000..a4173b4
--- /dev/null
+++ b/bin/varnishtest/tests/r01038.vtc
@@ -0,0 +1,62 @@
+varnishtest "ticket 1038 regression test"
+
+server s1 {
+ rxreq
+ txresp -nolen -hdr "Transfer-encoding: chunked"
+ chunked {<HTML>}
+
+
+ chunked {<esi:include src="xxx0.htm"/>}
+ chunked {<esi:include src="xxx1.htm"/>}
+ chunked {<esi:include src="xxx2.htm"/>}
+ chunked {<esi:include src="xxx3.htm"/>}
+ chunked {<esi:include src="xxx4.htm"/>}
+ chunked {<esi:include src="xxx5.htm"/>}
+ chunked {<esi:include src="xxx6.htm"/>}
+ chunked {<esi:include src="xxx7.htm"/>}
+ chunked {<esi:include src="xxx8.htm"/>}
+ chunkedlen 0
+ rxreq
+ expect req.url == "/xxx0.htm"
+ txresp -body "foo0"
+ rxreq
+ expect req.url == "/xxx1.htm"
+ txresp -body "foo1"
+ rxreq
+ expect req.url == "/xxx2.htm"
+ txresp -body "foo2"
+ rxreq
+ expect req.url == "/xxx3.htm"
+ txresp -body "foo3"
+ rxreq
+ expect req.url == "/xxx4.htm"
+ txresp -body "foo4"
+ rxreq
+ expect req.url == "/xxx5.htm"
+ txresp -body "foo5"
+ rxreq
+ expect req.url == "/xxx6.htm"
+ txresp -body "foo6"
+ rxreq
+ expect req.url == "/xxx7.htm"
+ txresp -body "foo7"
+ rxreq
+ expect req.url == "/xxx8.htm"
+ txresp -body "foo8"
+} -start
+
+varnish v1 -arg "-p thread_pool_workspace=1024" -vcl+backend {
+ sub vcl_fetch {
+ set beresp.do_esi = true;
+ }
+} -start
+
+client c1 {
+ txreq
+ rxresp
+ txreq
+ rxresp
+} -run
+
+varnish v1 -expect losthdr == 0
+
More information about the varnish-commit
mailing list