Commit ce079acd authored by Martin Blix Grydeland's avatar Martin Blix Grydeland

Finish range delivery processing when the range is delivered.

When doing range delivery, make the delivery processing finish early
when all of the bytes of the requested range has been delivered. This
to avoid waiting around for a slow fetch to finish before handling the
next request on the connection.

Fixes: #2035
parent ca9c4b59
......@@ -48,7 +48,6 @@ static int __match_proto__(vdp_bytes)
vrg_range_bytes(struct req *req, enum vdp_action act, void **priv,
const void *ptr, ssize_t len)
{
int retval = 0;
ssize_t l;
const char *p = ptr;
struct vrg_priv *vrg_priv;
......@@ -76,11 +75,11 @@ vrg_range_bytes(struct req *req, enum vdp_action act, void **priv,
if (l > len)
l = len;
if (l > 0)
retval = VDP_bytes(req, act, p, l);
(void)VDP_bytes(req, act, p, l);
else if (act > VDP_NULL)
retval = VDP_bytes(req, act, p, 0);
(void)VDP_bytes(req, act, p, 0);
vrg_priv->range_off += len;
return (retval);
return (vrg_priv->range_off >= vrg_priv->range_high ? 1 : 0);
}
/*--------------------------------------------------------------------*/
......
varnishtest "Streaming range early finish"
server s1 {
non-fatal
rxreq
txresp -nolen -hdr "Content-Length: 11"
# Delay to get around Nagle. Without the delay the body bytes
# would be in the same packet as the headers, and would end
# up as pipelined data. Pipelined data wouldn't create a streaming
# data event, breaking the test case.
delay 0.5
send_n 10 "A"
# Sema r1 halts the backend thread until client c1 is finished.
sema r1 sync 2
send "B"
} -start
varnish v1 -vcl+backend {
} -start
client c1 {
txreq -hdr "Range: bytes=0-4"
rxresp
expect resp.status == 206
expect resp.bodylen == 5
# The client thread should be ready to accept another request:
txreq -hdr "Range: bytes=5-9"
rxresp
expect resp.status == 206
expect resp.bodylen == 5
sema r1 sync 2
} -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