[BUG] http: don't set auto_close if more data are expected
authorWilly Tarreau <w@1wt.eu>
Sat, 28 Aug 2010 16:57:20 +0000 (18:57 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 28 Aug 2010 17:06:28 +0000 (19:06 +0200)
commit92aa1fac0a45fe4b6a834d8e3cf24ec24e793ac2
tree167310ce30ad6a73f377e1cdd1b53981e260f494
parentd0807c3c603f661ef74b9cbb580aeffdbbd7d712
[BUG] http: don't set auto_close if more data are expected

Fix 4fe41902789d188ee4c23b14a7cdbf075463b158 was a bit too strong. It
has caused some chunked-encoded responses to be truncated when a recv()
call could return multiple chunks followed by a close. The reason is
that when a chunk is parsed, only its contents are scheduled to be
forwarded. Thus, the reader sees auto_close+shutr and sets shutw_now.
The sender in turn sends the last scheduled data and does shutw().

Another nasty effect is that it has reduced the keep-alive rate. If
a response did not completely fit into the buffer, then the auto_close
bit was left on and the sender would close upon completion.

The fix consists in not making use of auto_close when chunked encoding
is used nor when keep-alive is used, which makes sense. However it is
maintained on error processing.

Thanks to Cyril Bonté for reporting the issue early.
src/proto_http.c