curl-library
Re: Wrong connection reuse - curl_easy_send/recv with curl_multi
Date: Mon, 18 Feb 2019 13:31:33 +0100
On Sat, 16 Feb 2019 at 16:11, Daniel Stenberg <daniel_at_haxx.se> wrote:
>
> Can you help us write up an example that reproduces this?
I've attached modified example from curl_multi_wait man page. I was
able to reproduce this with current master and also 7.64 release. The
relevant part of output I think is:
easy created 0x555cb4e93510
easyRaw created 0x555cb4e98ed0
* Expire in 0 ms for 6 (transfer 0x555cb4e98ed0)
* Expire in 0 ms for 6 (transfer 0x555cb4e93510)
* Uses proxy env variable http_proxy == 'http://127.0.0.1:9400'
* Trying 127.0.0.1...
* TCP_NODELAY set
* Expire in 200 ms for 4 (transfer 0x555cb4e98ed0)
* Connected to 127.0.0.1 (127.0.0.1) port 9400 (#0)
* Connection #0 to host 127.0.0.1 left intact
* Uses proxy env variable http_proxy == 'http://127.0.0.1:9400'
* Found bundle for host example.com: 0x555cb4ead2c0 [serially]
* Server doesn't support multi-use (yet)
* Re-using existing connection! (#0) with proxy 127.0.0.1
* Connected to 127.0.0.1 (127.0.0.1) port 9400 (#0)
> GET http://example.com/ HTTP/1.1
Host: example.com
Accept: */*
Proxy-Connection: Keep-Alive
0x555cb4e98ed0 is done
.
However I was only able to reproduce it with http proxy running on
localhost (tinyproxy 1.10.0). And another interesting fact is it only
happens when I use address in http_proxy variable. It does not occur
when it's set to name "localhost". So maybe it is a race between
connections/requests?
I have also tried to make some requests without proxy directly to
forking socat running on localhost and the connection was also reused.
So it looks like it's not bound to curl proxy functionality but it
seems more likely to be a timing issue (seems to happen when
connections are fast).
On Sat, 16 Feb 2019 at 16:11, Daniel Stenberg <daniel_at_haxx.se> wrote:
>
> On Thu, 14 Feb 2019, Pavel Löbl via curl-library wrote:
>
> > I want to use CURLOPT_CONNECT_ONLY/CURLINFO_ACTIVESOCKET with
> > curl_easy_send/recv to implement custom protocol using curl multi interface.
> >
> > I have multiple connections to the same host (behind a proxy). One of them
> > is marked with CURLOPT_CONNECT_ONLY. This one I want to use for custom
> > protocol traffic. However when another usual http request is made curl will
> > reuse the previous "connect only" connection. Thus blocking me from using it
> > for custom stuff.
> >
> > If I add CURLOPT_FORBID_REUSE it is closed immediately after connect.
> >
> > It just seems curl considers the connection as finished and ready to be
> > reused which is not true for curl_easy_send/recv use case.
>
> CURLOPT_CONNECT_ONLY connections should never be reused, period. By handing
> over the control of the connection to "outsiders" makes it impossible to do
> reliably (because curl no longer knows what was sent/received or the state of
> it). I think that if such a connection is considered for reuse as you say it
> is, that's a bug.
>
> Can you help us write up an example that reproduces this?
>
> --
>
> / daniel.haxx.se
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
- text/x-csrc attachment: reuse.c