aboutsummaryrefslogtreecommitdiff
path: root/lib/connect.c
AgeCommit message (Collapse)Author
2011-10-15singleipconnect: don't clobber errnoDaniel Stenberg
Save the errno value immediately after a connect() failure so that it won't get reset to something else before we read it. Bug: http://curl.haxx.se/mail/lib-2011-10/0066.html Reported by: Frank Van Uffelen and Fabian Hiernaux
2011-09-09tcpnodelay: rename variableDaniel Stenberg
Renamed the variable from 'proto' to 'level' simply because it is not protocol you set but level and that is the name of the argument used in man pages and the POSIX documentation of the setsockopt function.
2011-09-03fix a bunch of MSVC compiler warningsYang Tse
2011-08-19connect: set TIMER_CONNECTDaniel Stenberg
When connecting, make sure TIMER_CONNECT is set.
2011-08-18FTP: fix proxy connect race conditionDaniel Stenberg
When using the multi interface, a SOCKS proxy, and a connection that wouldn't immediately consider itself connected (which my Linux tests do by default), libcurl would be tricked into doing _two_ connects to the SOCKS proxy when it setup the data connection and then of course the second attempt would fail miserably and cause error. This problem is a regression that was introduced by commit 4a42e5cdaa344755 that was introduced in the 7.21.7 release. Bug: http://curl.haxx.se/mail/lib-2011-08/0199.html Reported by: Fabian Keil
2011-08-05BSD-style lwIP TCP/IP stack support - followupYang Tse
2011-07-26stdio.h, stdlib.h, string.h, stdarg.h and ctype.h inclusion done in setup_once.hYang Tse
2011-07-25time.h and sys/time.h inclusion conditionally done in setup_once.hYang Tse
2011-07-24errno.h inclusion conditionally done in setup_once.hYang Tse
2011-06-10unittest: mark all unit tested functionsDaniel Stenberg
With "@unittest: [num]" in the header comment for each tested function. Shows we have a log way to go still...
2011-06-04Curl_socket_ready: make timeout a 'long'Daniel Stenberg
It was mostly typecasted to int all over the code so switching to long instead all over should be a net gain.
2011-05-26compiler warning: fixYang Tse
Fix compiler warning: conversion may lose significant bits
2011-05-18CLOSESOCKETFUNCTION: use the callbackDaniel Stenberg
Fix the return type of the callback to match close() and make use of it.
2011-05-18CLOSESOCKETFUNCTION: addedDaniel Stenberg
Introduced the initial setup to allow closesocket callbacks by making sure sclose() is only ever called from one place in the libcurl source and still run all test cases fine.
2011-04-28multi-socks: fix connect to proxyDaniel Stenberg
When connecting to a socks or similar proxy we do the proxy handshake at once when we know the TCP connect is completed and we only consider the "connection" complete after the proxy handshake. This fixes test 564 which is now no longer considered disabled. Reported by: Dmitri Shubin Bug: http://curl.haxx.se/mail/lib-2011-04/0127.html
2011-04-27whitespace cleanup: no space first in conditionalsDaniel Stenberg
"if(a)" is our style, not "if( a )"
2011-04-27source cleanup: unify look, style and indent levelsDaniel Stenberg
By the use of a the new lib/checksrc.pl script that checks that our basic source style rules are followed.
2011-04-25async resolvers: further cleanupsDaniel Stenberg
asyn-ares.c and asyn-thread.c are two separate backends that implement the same (internal) async resolver API for libcurl to use. Backend is specified at build time. The internal resolver API is defined in asyn.h for asynch resolvers.
2011-04-21Fix a couple of spelling errors in lib/Fabian Keil
Found with codespell.
2011-04-11checkconnection: don't call with NULL pointerDaniel Stenberg
When checking if an existing RTSP connection is alive or not, the checkconnection function might be called with a SessionHandle pointer being NULL and then referenced causing a crash. This happened only using the multi interface. Reported by: Tinus van den Berg Bug: http://curl.haxx.se/bug/view.cgi?id=3280739
2011-02-17SOCKOPTFUNCTION: callback can say already-connectedDaniel Stenberg
Introducing a few CURL_SOCKOPT* defines for conveniance. The new CURL_SOCKOPT_ALREADY_CONNECTED signals to libcurl that the socket is to be treated as already connected and thus it will skip the connect() call.
2011-02-09CURLOPT_SOCKOPTFUNCTION: return proper error codeDaniel Stenberg
When the callback returns an error, this function must make sure to return CURLE_ABORTED_BY_CALLBACK properly and not CURLE_OK as before to allow the callback to properly abort the operation.
2011-01-11connect: use UDP correctlyDaniel Stenberg
The idea that the protocol and socktype is part of name resolving in the libc functions is nuts. We keep the name resolver functions assume TCP/STREAM and we make sure that when we want to connect to a UDP service we use the correct UDP/DGRAM set instead. This bug was because the ->protocol field was not always set correctly. This bug was only affecting ipv6-disabled non-cares non-threaded builds. Bug: http://curl.haxx.se/bug/view.cgi?id=3154436 Reported by: "dperham"
2011-01-04Curl_timeleft: s/conn/data in first argumentDaniel Stenberg
As the function doesn't really use the connectdata struct but only the SessionHanadle struct I modified what argument it wants.
2010-12-23multi: connect fail => use next IP addressDaniel Stenberg
When using the multi interface and connecting to a host name that resolves to multiple IP addresses, there was no logic that made it continue to the next IP if connecting to the first address times out. This is now corrected.
2010-12-03fix getinfo CURLINFO_LOCAL* for reused connections (take 2) follow-upYang Tse
- Show address string from proper buffer in case of connection failure. - Try next address when inet_ntop() fails.
2010-12-01connect: fix compiler warning: unused variableYang Tse
2010-11-30fix getinfo CURLINFO_LOCAL* for reused connections (take 2)Yang Tse
2010-11-30fix getinfo CURLINFO_LOCAL* for reused connections follow-upYang Tse
Reinstate IPV6 build variable that got removed.
2010-11-30fix getinfo CURLINFO_LOCAL* for reused connectionsYang Tse
2010-11-11ip_version: moved to connection structDaniel Stenberg
The IP version choice was previously only in the UserDefined struct within the SessionHandle, but since we sometimes alter that option during a request we need to have it on a per-connection basis. I also moved more "init conn" code into the allocate_conn() function which is designed for that purpose more or less.
2010-09-17Curl_timeleft: avoid returning "no timeout" by mistakeDaniel Stenberg
As this function uses return code 0 to mean that there is no timeout, it needs to check that it doesn't return a time left value that is exactly zero. It could lead to libcurl doing an extra 1000 ms select() call and thus not timing out as accurately as it should. I fell over this bug when working on the bug 3061535 but this fix does not correct that problem alone, although this is a problem that needs to be fixed. Reported by: Rodric Glaser Bug: http://curl.haxx.se/bug/view.cgi?id=3061535
2010-09-14multi: don't do extra expire calls for the connectionDaniel Stenberg
The timeout is set for the connect phase already at the start of the request so we should not add a new one, and we MUST not set expire to 0 as that will remove any other potentially existing timeouts.
2010-09-06portabilty: use proper variable type to hold socketsDaniel Stenberg
Curl_getconnectinfo() is changed to return a proper curl_socket_t for the last socket so that it'll work more portably (and cause less compiler warnings).
2010-08-21Curl_is_connected: use correct errnoDirk Manske
The correctly extracted errno contents were mistakenly overwritten by a newer value that wasn't the correct error value. Bug: http://curl.haxx.se/mail/lib-2010-08/0242.html
2010-08-10callbacks: acknowledge progress callback error returnsDaniel Stenberg
When the progress callback is called during the TCP connection, an error return would accidentally not abort the operation as intended but would instead be counted as a failure to connect to that particular IP and libcurl would just continue to try the next. I made singleipconnect() and trynextip() return CURLcode properly. Added bonus: it corrected the error code for bad --interface usages, like tested in test 1084 and test 1085. Reported by: Adam Light Bug: http://curl.haxx.se/mail/lib-2010-08/0105.html
2010-06-24multi_socket: re-use of same socket without notifying appDaniel Stenberg
When a hostname resolves to multiple IP addresses and the first one tried doesn't work, the socket for the second attempt may get dropped on the floor, causing the request to eventually time out. The issue is that when using kqueue (as on mac and bsd platforms) instead of select, the kernel removes the first fd from kqueue when it is closed (in trynextip, connect.c:503). Trynextip() then goes on to open a new socket, which gets assigned the same number as the one it just closed. Later in multi.c, socket_cb is not called because the fd is already in multi->sockhash, so the new socket is never added to kqueue. The correct fix is to ensure that socket_cb is called to remove the fd when trynextip() closes the socket, and again to re-add it after singleipsocket(). I'm not sure how to cleanly do that, but the attached patch works around the problem in an admittedly kludgy way by delaying the close to ensure that the newly-opened socket gets a different fd. Daniel's added comment: I didn't spot a way to easily do a nicer fix so I've proceeded with Ben's patch. Bug: http://curl.haxx.se/bug/view.cgi?id=3017819 Patch by: Ben Darnell
2010-06-08avoid redundant work when reusing same connectionYang Tse
2010-06-08fix function result checkingYang Tse
2010-06-07Curl_updateconninfo() error handling fixYang Tse
2010-06-05replace socklen_t with curl_socklen_tYang Tse
2010-06-05getinfo: added *_PRIMARY_PORT, *_LOCAL_IP and *_LOCAL_PORTFrank Meier
2010-05-07multi interface: missed storing connection timeDaniel Stenberg
Dirk Manske reported a regression. When connecting with the multi interface, there were situations where libcurl wouldn't store connect time correctly as it used to (and is documented to) do. Using his fine sample program we could repeat it, and I wrote up test case 573 using that code. The problem does not easily show itself using the local test suite though. The fix, also as suggested by Dirk, is a bit on the ugly side as it adds yet another call to Curl_verboseconnect() and setting the TIMER_CONNECT time. That situation is subject for some closer inspection in the future.
2010-03-24remove the CVSish $Id$ linesDaniel Stenberg
2010-03-23mark connection as connectedDaniel Stenberg
Kenny To filed the bug report #2963679 with patch to fix a problem he experienced with doing multi interface HTTP POST over a proxy using PROXYTUNNEL. He found a case where it would connect fine but bits.tcpconnect was not set correct so libcurl didn't work properly. (http://curl.haxx.se/bug/view.cgi?id=2963679)
2010-02-04fix printf-style format stringsYang Tse
2010-02-02Fix compiler warning: conditional expression is constantYang Tse
2010-01-28fix printf-style format stringsYang Tse
2010-01-22wrap long lines and do some indent policingDaniel Stenberg
2010-01-11- Made sure that the progress callback is repeatedly called at a regularDaniel Stenberg
interval even during very slow connects.