Commit 8721bc44 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp Committed by Tollef Fog Heen

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
parent 834dff69
......@@ -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);
......
......@@ -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)
......
......@@ -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);
......
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment