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

New fix for #2285 and #2624

Previous fix for #2285 (and the duplicate #2624) was missdiagnosed. The
problem stems from a wrong assumption that the number of bytes already
pipelined will be less than maxbytes, with maxbytes beeing the maximum
number of bytes the HTC_RxStuff may need to get a full work unit. That
assumption may fail during the H/1 to H/2 upgrade path where maxbytes
change with the context, or during runtime changing of parameters.

This patch makes HTC_RxStuff not assert if the pipelined data turned out
to exceed maxbytes, but return overflow if we run out of workspace.

(#2624 has received a workaround in the H/2 code that perhaps should be
reverted).
parent 9d1b135d
......@@ -239,6 +239,11 @@ HTC_RxPipeline(struct http_conn *htc, void *p)
/*----------------------------------------------------------------------
* Receive a request/packet/whatever, with timeouts
*
* maxbytes is the maximum number of bytes the caller expects to need to
* reach a complete work unit. Note that due to pipelining the actual
* number of bytes passed to func in htc->rxbuf_b through htc->rxbuf_e may
* be larger.
*
* t0 is when we start
* *t1 becomes time of first non-idle rx
* *t2 becomes time of complete rx
......@@ -261,6 +266,7 @@ HTC_RxStuff(struct http_conn *htc, htc_complete_f *func,
AN(htc->ws->r);
AN(htc->rxbuf_b);
assert(htc->rxbuf_b <= htc->rxbuf_e);
assert(htc->rxbuf_e <= htc->ws->r);
AZ(isnan(tn));
if (t1 != NULL)
......@@ -273,7 +279,7 @@ HTC_RxStuff(struct http_conn *htc, htc_complete_f *func,
}
z = (htc->ws->r - htc->rxbuf_b);
if (z < maxbytes)
maxbytes = z;
maxbytes = z; /* Cap maxbytes at available WS */
while (1) {
now = VTIM_real();
......@@ -308,8 +314,9 @@ HTC_RxStuff(struct http_conn *htc, htc_complete_f *func,
if (!isnan(ti) && ti < tn && hs == HTC_S_EMPTY)
tmo = ti - now;
z = maxbytes - (htc->rxbuf_e - htc->rxbuf_b);
assert(z >= 0);
if (z == 0) {
if (z <= 0) {
/* maxbytes reached but not HTC_S_COMPLETE. Return
* overflow. */
WS_ReleaseP(htc->ws, htc->rxbuf_b);
return (HTC_S_OVERFLOW);
}
......
......@@ -5,6 +5,8 @@ server s1 {
txresp
rxreq
txresp
rxreq
txresp
} -start
varnish v1 -arg "-p workspace_client=9k" -proto PROXY -vcl+backend {
......@@ -59,3 +61,8 @@ client c2 {
}
rxresp
} -run
client c3 {
send "PROXY TCP4 127.0.0.1 127.0.0.1 1111 2222\r\nGET /CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC HTTP/1.1\r\n\r\n"
rxresp
} -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