Commit 717f0fb9 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Spotted while looking for 1449:

Make sure we do not send a regular "end-chunk" to the
client if the streaming fetch fails.
parent 899b87ee
...@@ -157,7 +157,7 @@ v1d_dorange(struct req *req, const char *r) ...@@ -157,7 +157,7 @@ v1d_dorange(struct req *req, const char *r)
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
static void static enum objiter_status
v1d_WriteDirObj(struct req *req) v1d_WriteDirObj(struct req *req)
{ {
enum objiter_status ois; enum objiter_status ois;
...@@ -190,12 +190,14 @@ v1d_WriteDirObj(struct req *req) ...@@ -190,12 +190,14 @@ v1d_WriteDirObj(struct req *req)
} while (ois == OIS_DATA || ois == OIS_STREAM); } while (ois == OIS_DATA || ois == OIS_STREAM);
(void)VDP_bytes(req, VDP_FINISH, NULL, 0); (void)VDP_bytes(req, VDP_FINISH, NULL, 0);
ObjIterEnd(&oi); ObjIterEnd(&oi);
return (ois);
} }
void void
V1D_Deliver(struct req *req) V1D_Deliver(struct req *req)
{ {
char *r; char *r;
enum objiter_status ois;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC); CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC);
...@@ -291,6 +293,7 @@ V1D_Deliver(struct req *req) ...@@ -291,6 +293,7 @@ V1D_Deliver(struct req *req)
if (req->res_mode & RES_CHUNKED) if (req->res_mode & RES_CHUNKED)
WRW_Chunked(req->wrk); WRW_Chunked(req->wrk);
ois = OIS_DONE;
if (!req->wantbody) { if (!req->wantbody) {
/* This was a HEAD or conditional request */ /* This was a HEAD or conditional request */
} else if (req->res_mode & RES_ESI) { } else if (req->res_mode & RES_ESI) {
...@@ -305,17 +308,19 @@ V1D_Deliver(struct req *req) ...@@ -305,17 +308,19 @@ V1D_Deliver(struct req *req)
VDP_push(req, VDP_gunzip); VDP_push(req, VDP_gunzip);
req->vgz = VGZ_NewUngzip(req->vsl, "U D -"); req->vgz = VGZ_NewUngzip(req->vsl, "U D -");
AZ(VGZ_WrwInit(req->vgz)); AZ(VGZ_WrwInit(req->vgz));
v1d_WriteDirObj(req); ois = v1d_WriteDirObj(req);
(void)VGZ_Destroy(&req->vgz); (void)VGZ_Destroy(&req->vgz);
VDP_pop(req, VDP_gunzip); VDP_pop(req, VDP_gunzip);
} else { } else {
v1d_WriteDirObj(req); ois = v1d_WriteDirObj(req);
} }
if (req->res_mode & RES_CHUNKED && !(req->res_mode & RES_ESI_CHILD)) if (ois == OIS_DONE &&
(req->res_mode & RES_CHUNKED) &&
!(req->res_mode & RES_ESI_CHILD))
WRW_EndChunk(req->wrk); WRW_EndChunk(req->wrk);
if (WRW_FlushRelease(req->wrk) && req->sp->fd >= 0) if ((WRW_FlushRelease(req->wrk) || ois != OIS_DONE) && req->sp->fd >= 0)
SES_Close(req->sp, SC_REM_CLOSE); SES_Close(req->sp, SC_REM_CLOSE);
} }
......
varnishtest "Check that aborted backend body aborts client in streaming mode"
server s1 {
rxreq
txresp -nolen -hdr "Transfer-encoding: chunked"
chunked {<HTML>}
sema r1 sync 2
chunked {<HTML>}
sema r1 sync 2
} -start
varnish v1 -cliok "param.set debug +syncvsl" -vcl+backend {
} -start
client c1 {
txreq
rxresphdrs
expect resp.status == 200
rxchunk
sema r1 sync 2
rxchunk
sema r1 sync 2
expect_close
} -run
...@@ -65,9 +65,9 @@ varnish v1 -vcl+backend { ...@@ -65,9 +65,9 @@ varnish v1 -vcl+backend {
client c1 { client c1 {
txreq -hdr "Cookie: FOO" txreq -hdr "Cookie: FOO"
rxresp rxresphdrs
expect resp.status == 200 expect resp.status == 200
expect resp.bodylen == 0 expect_close
} -run } -run
delay .1 delay .1
......
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