cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-tracker Archives

[ curl-Bugs-3516508 ] Curl_connecthost brocken

From: SourceForge.net <noreply_at_sourceforge.net>
Date: Thu, 19 Apr 2012 14:34:09 -0700

Bugs item #3516508, was opened at 2012-04-10 07:44
Message generated for change (Settings changed) made by bagder
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=3516508&group_id=976

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: libcurl
Group: wrong behaviour
>Status: Closed
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: Blaise Potard (blaise2012)
Assigned to: Daniel Stenberg (bagder)
Summary: Curl_connecthost brocken

Initial Comment:
Curl_connecthost will fail immediately if a call to socket() fails.

If the dns resolver returns several records, some of which being unavailable on the system, Curl_connecthost() will fail (and return CURL_FAILED_INIT, which seems wrong) on the first dns record without trying the other records.

I have traced the regression to this commit:

https://github.com/bagder/curl/commit/9109cdec11ee5a19f132fd7bdf2e9ceefea4de41#lib/connect.c

You will observe that the "return CURLE_OK" when the call to socket() fails has been silently replaced by "return CURL_FAILED_INIT"; which do not seem to be the most appropriate error code; furthermore, singleipconnect / Curl_connecthost should be modified appropriately to handle the new behaviour.

Regards,
Blaise

----------------------------------------------------------------------

Comment By: Daniel Stenberg (bagder)
Date: 2012-04-19 14:34

Message:
Thanks for the report, this problem is now fixed in the git repository.

To try it out, you either checkout/update your git clone:
http://curl.haxx.se/source.html

or you try tomorrow's daily snapshot: http://curl.haxx.se/snapshots/

----------------------------------------------------------------------

Comment By: Blaise Potard (blaise2012)
Date: 2012-04-19 02:50

Message:
Thanks for the prompt fix!

It does appear to fix the problem.

However, I am slightly concerned that singleipconnect is performing many
operations that do not seem to be relevant after the Curl_socket call
fails. Maybe it would better to simply modify singleipconnect to return
CURLE_OK when the call to Curl_socket fails?
-------------------------------------------------------
diff --git a/lib/connect.c b/lib/connect.c
index 2d59229..ac6d2a7 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -881,7 +881,10 @@ singleipconnect(struct connectdata *conn,
 
   res = Curl_socket(conn, ai, &addr, &sockfd);
   if(res)
- return res;
+ /* No socket, but still return OK since we signal the bad socket
anyway
+ and we have a legacy of doing it this way. This will allow the
parent function
+ to keep looping over alternative addresses/socket families etc. */
+ return CURLE_OK;
 
   /* store remote address and port used in this connection attempt */
   if(!getaddressinfo((struct sockaddr*)&addr.sa_addr,

----------------------------------------------------------------------

Comment By: Daniel Stenberg (bagder)
Date: 2012-04-18 14:16

Message:
Ok, see the attached patch. It basically restores the old way of working.
Can you verify that it fixes the problem for you?

----------------------------------------------------------------------

Comment By: Daniel Stenberg (bagder)
Date: 2012-04-17 15:40

Message:
Ack, seems like an entirely correct analysis. Thanks! I'll work on fixing
it.

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=3516508&group_id=976
Received on 2012-04-19

These mail archives are generated by hypermail.

donate! Page updated January 05, 2012.
web site info

File upload with ASP.NET