summaryrefslogtreecommitdiff
path: root/lib/connect.c
Commit message (Collapse)AuthorAgeFilesLines
* connection cache: avoid Curl_hash_alloc()Daniel Stenberg2015-05-121-2/+2
| | | | | ... by using plain structs instead of pointers for the connection cache, we can avoid several dynamic allocations that weren't necessary.
* curl_memory: make curl_memory.h the second-last header file loadedDan Fandrich2015-03-241-2/+2
| | | | | | | This header file must be included after all header files except memdebug.h, as it does similar memory function redefinitions and can be similarly affected by conflicting definitions in system or dependent library headers.
* curl_easy_recv/send: make them work with the multi interfaceYamada Yasuharu2015-03-231-4/+9
| | | | | By making sure Curl_getconnectinfo() uses the correct connection cache to find the last connection.
* checksrc: use space after commaDaniel Stenberg2015-03-171-2/+2
|
* connect: Fix happy eyeballs logic for IPv4-only buildsJay Satiro2015-03-161-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: https://github.com/bagder/curl/pull/168 (trynextip) - Don't try the "other" protocol family unless IPv6 is available. In an IPv4-only build the other family can only be IPv6 which is unavailable. This change essentially stops IPv4-only builds from attempting the "happy eyeballs" secondary parallel connection that is supposed to be used by the "other" address family. Prior to this change in IPv4-only builds that secondary parallel connection attempt could be erroneously used by the same family (IPv4) which caused a bug where every address after the first for a host could be tried twice, often in parallel. This change fixes that bug. An example of the bug is shown below. Assume MTEST resolves to 3 addresses 127.0.0.2, 127.0.0.3 and 127.0.0.4: * STATE: INIT => CONNECT handle 0x64f4b0; line 1046 (connection #-5000) * Rebuilt URL to: http://MTEST/ * Added connection 0. The cache now contains 1 members * STATE: CONNECT => WAITRESOLVE handle 0x64f4b0; line 1083 (connection #0) * Trying 127.0.0.2... * STATE: WAITRESOLVE => WAITCONNECT handle 0x64f4b0; line 1163 (connection #0) * Trying 127.0.0.3... * connect to 127.0.0.2 port 80 failed: Connection refused * Trying 127.0.0.3... * connect to 127.0.0.3 port 80 failed: Connection refused * Trying 127.0.0.4... * connect to 127.0.0.3 port 80 failed: Connection refused * Trying 127.0.0.4... * connect to 127.0.0.4 port 80 failed: Connection refused * connect to 127.0.0.4 port 80 failed: Connection refused * Failed to connect to MTEST port 80: Connection refused * Closing connection 0 * The cache now contains 0 members * Expire cleared curl: (7) Failed to connect to MTEST port 80: Connection refused The bug was born in commit bagder/curl@2d435c7.
* closesocket: call multi socket cb on close even with custom closeFrank Meier2015-03-151-1/+3
| | | | | | | | | | | In function Curl_closesocket() in connect.c the call to Curl_multi_closed() was wrongly omitted if a socket close function (CURLOPT_CLOSESOCKETFUNCTION) is registered. That would lead to not removing the socket from the internal hash table and not calling the multi socket callback appropriately. Bug: http://curl.haxx.se/bug/view.cgi?id=1493
* conncontrol: only log changes to the connection bitDaniel Stenberg2015-03-071-5/+6
|
* mprintf.h: remove #ifdef CURLDEBUGDaniel Stenberg2015-03-031-3/+1
| | | | | ... and as a consequence, introduce curl_printf.h with that re-define magic instead and make all libcurl code use that instead.
* connect: wait for IPv4 connection attemptsKamil Dudka2015-02-231-2/+7
| | | | | | ... even if the last IPv6 connection attempt has failed. Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1187531#c4
* connect: avoid skipping an IPv4 addressKamil Dudka2015-02-231-2/+6
| | | | | | | ... in case the protocol versions are mixed in a DNS response (IPv6 -> IPv4 -> IPv6). Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1187531#c3
* ipv6: enclose AF_INET6 uses with proper #ifdefs for ipv6Daniel Stenberg2015-01-201-3/+11
| | | | Reported-by: Chris Young
* code/docs: Use correct case for IPv4 and IPv6Steve Holme2014-12-271-2/+2
| | | | | | For consistency, as we seem to have a bit of a mixed bag, changed all instances of ipv4 and ipv6 in comments and documentations to use the correct case.
* IPV6: address scope != scope idPatrick Monnerat2014-12-161-5/+7
| | | | | | | | | | | | | | | | | | There was a confusion between these: this commit tries to disambiguate them. - Scope can be computed from the address itself. - Scope id is scope dependent: it is currently defined as 1-based local interface index for link-local scoped addresses, and as a site index(?) for (obsolete) site-local addresses. Linux only supports it for link-local addresses. The URL parser properly parses a scope id as an interface index, but stores it in a field named "scope": confusion. The field has been renamed into "scope_id". Curl_if2ip() used the scope id as it was a scope. This caused failures to bind to an interface. Scope is now computed from the addresses and Curl_if2ip() matches them. If redundantly specified in the URL, scope id is check for mismatch with the interface index. This commit should fix SF bug #1451.
* connect: singleipconnect(): properly try other address families after failurePatrick Monnerat2014-12-161-1/+1
|
* updateconninfo: clear destination struct before getsockname()Daniel Stenberg2014-12-041-0/+1
| | | | | Otherwise we may read uninitialized bytes later in the unix-domain sockets case.
* lib/connect: restrict IP/TCP options to said socketsPeter Wu2014-11-301-11/+15
| | | | | | | | | | This patch prepares for adding UNIX domain sockets support. TCP_NODELAY and TCP_KEEPALIVE are specific to TCP/IP sockets, so do not apply these to other socket types. bindlocal only works for IP sockets (independent of TCP/UDP), so filter that out too for other types. Signed-off-by: Peter Wu <peter@lekensteyn.nl>
* multi: inform about closed sockets before they are closedJon Spencer2014-11-191-1/+2
| | | | | | | | | When the connection code decides to close a socket it informs the multi system via the Curl_multi_closed function. The multi system may, in turn, invoke the CURLMOPT_SOCKETFUNCTION function with CURL_POLL_REMOVE. This happens after the socket has already been closed. Reorder the code so that CURL_POLL_REMOVE is called before the socket is closed.
* debug: added new connection cache output, plus fixupsCarlo Wood2014-11-181-1/+1
| | | | | | | | | | | | | Debug output 'typo' fix. Don't print an extra "0x" in * Pipe broke: handle 0x0x2546d88, url = / Add debug output. Print the number of connections in the connection cache when adding one, and not only when one is removed. Fix typos in comments.
* connect.c: Fixed compilation warning when no verbose string supportSteve Holme2014-11-161-0/+5
| | | | warning: unused parameter 'reason'
* code cleanup: Use 'CURLcode result'Steve Holme2014-10-301-4/+5
|
* code cleanup: We prefer 'CURLcode result'Steve Holme2014-10-281-15/+15
|
* code cleanup: we prefer 'CURLcode result'Daniel Stenberg2014-10-241-21/+20
| | | | | | | | | | | | | | ... for the local variable name in functions holding the return code. Using the same name universally makes code easier to read and follow. Also, unify code for checking for CURLcode errors with: if(result) or if(!result) instead of if(result == CURLE_OK), if(CURLE_OK == result) or if(result != CURLE_OK)
* cleanups: reduce variable scopeDaniel Stenberg2014-10-141-8/+9
| | | | cppcheck pointed these out.
* singleipconnect: remove dead assignment never usedDaniel Stenberg2014-10-141-1/+1
| | | | cppcheck pointed this out.
* nonblock: call with (void) to show we ignore the return codeDaniel Stenberg2014-10-041-1/+1
| | | | Coverity pointed out several of these.
* low-speed-limit: avoid timeout floodDaniel Stenberg2014-08-311-1/+1
| | | | | | | | | | | | | | | | | | | | Introducing Curl_expire_latest(). To be used when we the code flow only wants to get called at a later time that is "no later than X" so that something can be checked (and another timeout be added). The low-speed logic for example could easily be made to set very many expire timeouts if it would be called faster or sooner than what it had set its own timer and this goes for a few other timers too that aren't explictiy checked for timer expiration in the code. If there's no condition the code that says if(time-passed >= TIME), then Curl_expire_latest() is preferred to Curl_expire(). If there exists such a condition, it is on the other hand important that Curl_expire() is used and not the other. Bug: http://curl.haxx.se/mail/lib-2014-06/0235.html Reported-by: Florian Weimer
* win32: Fixed WinSock 2 #ifHaris Okanovic2014-08-211-1/+1
| | | | | | | | A conditionally compiled block in connect.c references WinSock 2 symbols, but used `#ifdef HAVE_WINSOCK_H` instead of `#ifdef HAVE_WINSOCK2_H`. Bug: http://curl.haxx.se/mail/lib-2014-08/0155.html
* compiler warnings: potentially uninitialized variablesMarcel Raad2014-07-051-1/+1
| | | | | | ... pointed out by MSVC2013 Bug: http://curl.haxx.se/bug/view.cgi?id=1391
* bits.close: introduce connection close trackingDaniel Stenberg2014-05-221-0/+17
| | | | | | | Make all code use connclose() and connkeep() when changing the "close state" for a connection. These two macros take a string argument with an explanation, and debug builds of curl will include that in the debug output. Helps tracking connection re-use/close issues.
* timers: fix timer regression involving redirects / reconnectsDaniel Stenberg2014-05-151-1/+6
| | | | | | | | | | | | | | | | | | | | In commit 0b3750b5c23c25f (released in 7.36.0) we fixed a timeout issue but instead broke the timings. To fix this, I introduce a new timestamp to use for the timeouts and restored the previous timestamp and timestamp position so that the old timer functionality is restored. In addition to that, that change also broke connection timeouts for when more than one connect was used (as it would then count the total time from the first connect and not for the most recent one). Now Curl_timeleft() has been modified so that it checks against different start times depending on which timeout it checks. Test 1303 is updated accordingly. Bug: http://curl.haxx.se/mail/lib-2014-05/0147.html Reported-by: Ryan Braud
* connect.c: fix multiple possible dereferences of null pointersMarc Hoersken2014-04-181-8/+10
| | | | | In case the first address in the tempaddr array is NULL, the code would previously dereference an unchecked null pointer.
* trynextip: don't store 'ai' on failed connects...Daniel Stenberg2014-03-191-1/+1
| | | | | | | | It leads to the "next family" tries starting from the wrong point and thus fails! Bug: http://curl.haxx.se/bug/view.cgi?id=1337 Reported-by: ricker
* win32: Added additional preprocessor check for Version Helper APISteve Holme2014-01-181-1/+2
| | | | | A follow up patch to commit d2671340a613 as _WIN32_WINNT_WIN2K and _WIN32_WINNT_WIN2K may not be defined on all systems.
* win32: Corrected the preprocessor check for Version Helper APISteve Holme2014-01-171-1/+1
| | | | | Following some auto build failures after commit c7a76bb056f31e changed the preprocessor check to use _WIN32_WINNT.
* connect.c:942:84: warning: Longer than 79 columnsDaniel Stenberg2014-01-161-1/+2
|
* connect.c: Corrected version compare in commit c7a76bb056f31eSteve Holme2014-01-151-1/+1
|
* win32: Fixed use of deprecated function 'GetVersionInfoEx' for VC12Steve Holme2014-01-151-3/+21
| | | | | | | | Starting with Visual Studio 2013 (VC12) and Windows 8.1 the GetVersionInfoEx() function has been marked as deprecated and it's return value atered. Updated connect.c and curl_sspi.c to use VerifyVersionInfo() where possible, which has been available since Windows 2000.
* multi: remove MULTI_TIMEOUT_INACCURACYDaniel Stenberg2014-01-121-2/+1
| | | | | | | | | | | | With the recently added timeout "reminder" functionality, there's no reason left for us to execute timeout code before the time is ripe. Simplifies the handling too. This will make the *TIMEOUT and *CONNECTTIMEOUT options more accurate again, which probably is most important when the *_MS versions are used. In multi_socket, make sure to update 'now' after having handled activity on a socket.
* Curl_updateconninfo: don't do anything for UDP "connections"Daniel Stenberg2014-01-081-0/+4
| | | | | | | getpeername() doesn't work for UDP sockets since they're not connected Reported-by: Priyanka Shah Bug: http://curl.haxx.se/mail/archive-2014-01/0016.html
* trynextip: fix build for non-IPV6 capable systemsDaniel Stenberg2014-01-081-1/+5
| | | | | | | AF_INET6 may not exist then Patched-by: Iida Yosiaki Bug: http://curl.haxx.se/bug/view.cgi?id=1322
* connect.c: Fixed compilation warningSteve Holme2013-12-281-1/+1
| | | | warning: 'res' may be used uninitialized in this function
* connect: Try all addresses in first connection attemptBjörn Stenberg2013-12-281-6/+6
| | | | | | | | | | | | Fixes a bug when all addresses in the first family fail immediately, due to "Network unreachable" for example, curl would hang and never try the next address family. Iterate through all address families when to trying establish the first connection attempt. Bug: http://curl.haxx.se/bug/view.cgi?id=1315 Reported-by: Michal Górny and Anthony G. Basile
* vtls: renamed sslgen.[ch] to vtls.[ch]Daniel Stenberg2013-12-201-1/+1
|
* vtls: created subdir, moved sslgen.[ch] there, updated all include linesDaniel Stenberg2013-12-201-1/+1
|
* Curl_is_connected: use proxy name in error message when proxy is usedDaniel Stenberg2013-12-041-1/+2
| | | | | | | (bug introduced in 255826c4, never present in a release) Reported-by: Dima Tisnek Bug: http://curl.haxx.se/mail/lib-2013-12/0006.html
* connect: Try next ip directly after immediate connect failBjörn Stenberg2013-11-271-6/+13
| | | | | | | This fixes a rare Happy Eyeballs bug where if the first IP family runs out of addresses before the second-family-timer fires, and the second IP family's first connect fails immediately, no further IPs of the second family are attempted.
* connect: Close open but unconnected socket in singleipconnect()Steve Holme2013-11-171-6/+10
| | | | | | | | | singleipconnect() could return the file descriptor of an open socket even though the function returned a CURLE_COULDNT_CONNECT error code from commit ed1662c374361a and 02fbc26d59c591. This could cause tests 19, 704 and 1233 to fail on FreeBSD, AIX and Solaris.
* connect: Forgot to correct line endings before push in commit ed1662c374361aSteve Holme2013-11-141-2/+2
|
* connect: Return the socket descriptor even on failBjörn Stenberg2013-11-141-3/+2
| | | | | | singleipconnect() did not return the open socket descriptor on some errors, thereby sometimes causing a socket leak. This patch ensures the socket is always returned.
* connect: Close temporary sockets in conn_free()Björn Stenberg2013-11-101-1/+4
| | | | | The temporary sockets used for Happy Eyeballs were not closed properly, if curl exited prematurely, which this patch fixes.