cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: re-connect attempts with multiple A/AAAA recs

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 30 Jun 2008 13:49:27 +0200 (CEST)

On Sat, 28 Jun 2008, Lubo? Dole?el wrote:

> I have a domain name that has both an AAAA and an A record, but the tricky
> thing is that FTP is available only via IPv4.
>
> Now I'm doing all the socket monitoring myself via Linux epoll() and CURL
> calls my callback function to add/mod/remove sockets from the set.
>
> As you can see in the log, CURL tries IPv6, adds a socket into the set, my
> loop receives a failure and CURL then tries IPv4.
>
> CurlPoller::addTransfer 0x98b0b0
> No events
> CURL debug: "About to connect() to dolezel.info port 21 (#0)"
> CURL debug: "Trying 2002:515b:54e3::1..."
> CurlPoller::socket_callback - add/mod
> Events: CURL_CSELECT_ERR
> CURL debug: "Connection refused"
> CURL debug: "Trying 81.91.84.227..."
> No events
> No events
>
> There comes the problem. It never tells me about the new IPv4 socket (but
> according to Wireshark it really does connect). It either reuses the socket
> used for IPv6 (and the fault is mine, there would be something broken in my
> poller) or it creates a new one, but doesn't notify me.

It does sound pretty similar to the related socket-notifying problem we fixed
a couple of days ago. I _suspect_ this happens because libcurl only polls the
socket-usage at a few spots and if the code then has closed and re-created a
socket it doesn't notice and thus doesn't tell the app about it.

This habit exits because I hadn't properly considered that the closing of
sockets always need to be told, even if the same socket number is used in the
subsequent created one.

> I think you can use the same demonstration program I sent for the SFTP
> problem a few days ago. If you had time to find the bug or anything, I would
> be really grateful. I can look into CURL's source code too, but I guess it
> would take really long for me to locate the problem and fix it :-(

I've been very busy lately and I've not even had a chance to look at the SFTP
problem yet. Rather than waiting for me to catch up with my backlogged work,
I'd suggest you use my guidance above and try to pinpoint this yourself. I'll
join in as soon as I can.

-- 
  / daniel.haxx.se
Received on 2008-06-30