[erlang-bugs] httpc: Duplicate requests sent on long-running request sending

Eric Meadows-Jönsson eric.meadows.jonsson@REDACTED
Wed Nov 12 01:02:56 CET 2014


Duplicate requests will be sent when you have already run a request against
the same host and therefor have an existing keep-alive connection open. If
you then perform a request where the request body takes more than five
seconds to send a second identical request will be sent concurrently.

I think I have figured what is happening after tracing httpc.

The code reaches
https://github.com/erlang/otp/blob/ec8e9a96bd0d0148df5008b0665da0725e5b3f92/lib/inets/src/http_client/httpc_manager.erl#L851
and calls `httpc_handler:send` which blocks while sending the request. If
the request body takes longer than five seconds to send the
`gen_server:call` will timeout and reach this code
https://github.com/erlang/otp/blob/ec8e9a96bd0d0148df5008b0665da0725e5b3f92/lib/inets/src/http_client/httpc_manager.erl#L856.
`start_handler` will create a new connection sending another identical
request even though a request is already in progress.

I would be happy to provide a patch after some guidance on what the fix
should be. Maybe the `handle_call` in `httpc_handler` should return
immediately and the request be sent without blocking the caller?

-- 
Eric Meadows-Jönsson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20141112/7f02877b/attachment.htm>


More information about the erlang-bugs mailing list