Commit 8c0af333 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Fix an attempt to double close a session.

In future versions of HTTP requests can be terminated abnormally
without ditching the entire session, and this change starts the
transition to that logic.

Fixes: #1732
parent 7333dde2
......@@ -991,6 +991,7 @@ void VRG_dorange(struct req *req, const char *r);
struct req *Req_New(const struct worker *, struct sess *);
void Req_Release(struct req *);
int Req_Cleanup(struct sess *sp, struct worker *wrk, struct req *req);
void Req_Fail(struct req *req, enum sess_close reason);
/* cache_session.c [SES] */
struct sess *SES_New(struct sesspool *);
......
......@@ -59,7 +59,7 @@ vrg_range_bytes(struct req *req, enum vdp_action act, void **priv,
CAST_OBJ_NOTNULL(vrg_priv, *priv, VRG_PRIV_MAGIC);
if (act == VDP_FINI) {
if (vrg_priv->range_off < vrg_priv->range_high)
SES_Close(req->sp, SC_RANGE_SHORT);
Req_Fail(req, SC_RANGE_SHORT);
*priv = NULL; /* struct on ws, no need to free */
return (0);
}
......
......@@ -203,3 +203,15 @@ Req_Cleanup(struct sess *sp, struct worker *wrk, struct req *req)
WS_Reset(wrk->aws, NULL);
return (0);
}
/*----------------------------------------------------------------------
*/
void __match_proto__()
Req_Fail(struct req *req, enum sess_close reason)
{
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
if (req->sp->fd >= 0)
SES_Close(req->sp, reason);
}
varnishtest "range related panic"
server s1 {
rxreq
txresp -nolen -hdr "Transfer-Encoding: chunked"
chunkedlen 10
chunkedlen 10
sema r1 sync 2
chunkedlen 10
chunkedlen 10
chunkedlen 10
chunkedlen 0
delay .1
sema r2 sync 2
} -start
varnish v1 -vcl+backend {
} -start
client c1 {
txreq -hdr "Range: bytes=0-100"
rxresphdrs
expect resp.status == 206
expect resp.http.Content-Range == "bytes 0-100/*"
} -run
delay .1
sema r1 sync 2
sema r2 sync 2
delay .4
client c1 {
txreq -hdr "Range: bytes=0-100"
rxresp
expect resp.status == 206
expect resp.http.Content-Range == "bytes 0-49/50"
} -run
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