cmullaparthi/ibrowse — pull request #62 by Mistagrooves (2012-02-14 17:35:13+00:00)
Title: Ibrowse_lb process shuts down before all the connections are closed.

I encountered this issue in the following scenario:

1. Request details of resource with HEAD request.
2. If 404, upload file with chunked encoding.

What happens is the that the connection for the HEAD request will timeout after receiving its reply, closing the pipeline and 'EXIT'ing. This is caught by the ibrowse_lb process (line 171), resulting in it removing it from the ets table, and settings a gen_server timeout of 10000. After this expires (line 198) the ibrowse_lb process will start a timer to send itself the shutdown atom and complete the shutdown.

If a connection is still open, for a long upload, the ets table that it is using is destroyed resulting in a error when the connection process finally completes and it tries to increment the pipeline counter (ibrowse_http_client:1798).

Fix is to only start the timeout when we know we have 0 ongoing sessions.