]> git.ipfire.org Git - thirdparty/squid.git/commit
Bug 3420: Request body consumption races and !theConsumer exception.
authorAlex Rousskov <rousskov@measurement-factory.com>
Sat, 14 Jan 2012 07:19:41 +0000 (00:19 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 14 Jan 2012 07:19:41 +0000 (00:19 -0700)
commit079a3d0959135d260a186d35a51f881230396844
tree874d483a2d5cd53593270885de249254e62892b5
parent4af4396035dd03451c0d815f74d71f04577a7a2b
Bug 3420: Request body consumption races and !theConsumer exception.

Also fixes endless waiting for HTTP client to send req body we no longer need.

Before these changes, the client side used a single "closing" state to
handle two different error conditions:

  1. We stopped receiving request body because of some error.
  2. We stopped sending response because of some error.

When a "directional" error occurred, we try to keep the transaction going in
the other direction (e.g., to give ICAP the entire request or to give HTTP
client the entire response). However, because there was just one "closing"
state, the code failed to correctly detect or process many corner cases,
resulting in stuck transactions and !theConsumer assertions/exceptions due to
races between enableAutoConsumption() and expectNoConsumption() calls.

This patch replaces the "closing" state with two direction-specific "we
stopped sending/receiving" flags.

Now, when the response sending code is done, it now checks whether the
receiving code stopped and closes the connection as needed. This is done both
when we encounter a sending error (ClientSocketContext::initiateClose) and
when we successfully sent the entire response to the client
(ClientSocketContext::keepaliveNextRequest).

Similarly, when the request body reading code is done, it now checks whether
the receiving code stopped and closes the connection as needed. This is done
both when we encounter a receiving error
(ConnStateData::noteBodyConsumerAborted) and when we successfully receive the
entire request body from the client (ClientSocketContext::writeComplete).

TODO: This patch focuses on various error cases. We might still have problems
when there is an early HTTP response and no errors of any kind. I marked the
corresponding old code with an XXX.
src/client_side.cc
src/client_side.h