[3.0] 8721bc4 Also snapshot the worker thread workspace around esi:include processing.
Tollef Fog Heen
tfheen at varnish-cache.org
Mon Apr 16 10:20:34 CEST 2012
commit 8721bc447d38d4f4e4faaea0dd8cf95e1cdccc92
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
Conflicts:
bin/varnishd/cache_center.c
bin/varnishd/cache_response.c
diff --git a/bin/varnishd/cache_center.c b/bin/varnishd/cache_center.c
index 7f9198f..6cbd532 100644
--- a/bin/varnishd/cache_center.c
+++ b/bin/varnishd/cache_center.c
@@ -468,7 +468,7 @@ cnt_error(struct sess *sp)
http_PutStatus(h, sp->err_code);
TIM_format(TIM_real(), date);
http_PrintfHeader(w, sp->fd, h, "Date: %s", date);
- http_PrintfHeader(w, sp->fd, h, "Server: Varnish");
+ http_SetHeader(w, sp->fd, h, "Server: Varnish");
if (sp->err_reason != NULL)
http_PutResponse(w, sp->fd, h, sp->err_reason);
@@ -728,8 +728,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->fd, sp->wrk->beresp,
- "Content-Encoding: %s", "gzip");
+ http_SetHeader(sp->wrk, sp->fd, 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);
@@ -1194,7 +1194,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->fd, sp->wrk->bereq,
+ http_SetHeader(sp->wrk, sp->fd, sp->wrk->bereq,
"Accept-Encoding: gzip");
}
sp->wrk->connect_timeout = 0;
@@ -1398,7 +1398,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->fd, sp->http,
+ http_SetHeader(sp->wrk, sp->fd, 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 61555bf..bbf51fd 100644
--- a/bin/varnishd/cache_esi_deliver.c
+++ b/bin/varnishd/cache_esi_deliver.c
@@ -47,7 +47,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;
@@ -66,7 +67,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') {
@@ -116,7 +118,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 73338f7..b27c8af 100644
--- a/bin/varnishd/cache_response.c
+++ b/bin/varnishd/cache_response.c
@@ -130,7 +130,7 @@ RES_BuildHttp(const struct sess *sp)
}
if (sp->wrk->res_mode & RES_CHUNKED)
- http_PrintfHeader(sp->wrk, sp->fd, sp->wrk->resp,
+ http_SetHeader(sp->wrk, sp->fd, sp->wrk->resp,
"Transfer-Encoding: chunked");
TIM_format(TIM_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