httpc: Duplicate requests sent on long-running request sending

Eric Meadows-Jönsson <[email protected]>
Newsgroups gmane.comp.lang.erlang.bugs
Message-ID <CAM_eapieo=qjgPkJOau8Uh8iz79sh5WX5jCemwAQLMPifuNmvA@mail.gmail.com>
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

_______________________________________________
erlang-bugs mailing list
[email protected]
http://erlang.org/mailman/listinfo/erlang-bugs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.