aboutsummaryrefslogtreecommitdiff
path: root/lib/connect.c
AgeCommit message (Collapse)Author
2012-12-28build: make use of 76 lib/*.h renamed filesYang Tse
76 private header files renamed to use our standard naming scheme. This change affects 322 files in libcurl's source tree.
2012-12-14setup_once.h: refactor inclusion of <unistd.h> and <sys/socket.h>Yang Tse
Inclusion of top two most included header files now done in setup_once.h
2012-12-07Introducing a new persistent connection caching system using "bundles".Linus Nielsen Feltzing
A bundle is a list of all persistent connections to the same host. The connection cache consists of a hash of bundles, with the hostname as the key. The benefits may not be obvious, but they are two: 1) Faster search for connections to reuse, since the hash lookup only finds connections to the host in question. 2) It lays out the groundworks for an upcoming patch, which will introduce multiple HTTP pipelines. This patch also removes the awkward list of "closure handles", which were needed to send QUIT commands to the FTP server when closing a connection. Now we allocate a separate closure handle and use that one to close all connections. This has been tested in a live system for a few weeks, and of course passes the test suite.
2012-11-07Curl_connecthost: friendlier "couldn't connect" messageLars Buitinck
2012-07-22keepalive: multiply value for OS-specific unitsDaniel Stenberg
DragonFly uses milliseconds, while our API and Linux use full seconds. Reported by: John Marino Bug: http://curl.haxx.se/bug/view.cgi?id=3546257
2012-06-12Revert "connect.c/ftp.c: Fixed dereferencing pointer breakin strict-aliasing"Yang Tse
This reverts commit 9c94236e6cc078a0dc5a78b6e2fefc1403e5375e. It didn't server its purpose, so lets go back to long-time working code.
2012-06-11connect.c/ftp.c: Fixed dereferencing pointer breakin strict-aliasingMarc Hoersken
Fixed warning: dereferencing pointer does break strict-aliasing rules by using a union instead of separate pointer variables. Internal union sockaddr_u could probably be moved to generic header. Thanks to Paul Howarth for the hint about using unions for this. Important for winbuild: Separate declaration of sockaddr_u pointer. The pointer variable *sock cannot be declared and initialized right after the union declaration. Therefore it has to be a separate statement.
2012-04-19singleipconnect: return OK even when Curl_socket() failsDaniel Stenberg
Commit 9109cdec11ee5a brought this regression (shipped since 7.24.0). The singleipconnect() function must not return an error if Curl_socket() returns an error. It should then simply return OK and pass a SOCKET_BAD back simply because that is how the user of this function expects it to work and something else is not fine. Reported by: Blaise Potard Bug: http://curl.haxx.se/bug/view.cgi?id=3516508
2012-04-03connect.c: return changed to CURLE_COULDNT_CONNECT when opensocket failsLijo Antony
Curl_socket returns CURLE_COULDNT_CONNECT when the opensocket callback returns CURL_SOCKET_BAD. Previous return value CURLE_FAILED_INIT conveys incorrect information to the user.
2012-03-20fix several compiler warningsYang Tse
2012-03-16fix some compiler warningsYang Tse
2012-02-09add library support for tuning TCP_KEEPALIVEDave Reisner
This adds three new options to control the behavior of TCP keepalives: - CURLOPT_TCP_KEEPALIVE: enable/disable probes - CURLOPT_TCP_KEEPIDLE: idle time before sending first probe - CURLOPT_TCP_KEEPINTVL: delay between successive probes While not all operating systems support the TCP_KEEPIDLE and TCP_KEEPINTVL knobs, the library will still allow these options to be set by clients, silently ignoring the values.
2012-01-28more resilient connection times among IP addressesPierre Ynard
When connecting to a domain with multiple IP addresses, allow different, decreasing connection timeout values. This should guarantee some connections attempts with sufficiently long timeouts, while still providing fallback.
2012-01-28remove write-only variablePierre Ynard
2012-01-16add LF termination to infof() trace stringYang Tse
2011-12-20timeleft_accept: ack global timeout, moved to ftp.cDaniel Stenberg
First off the timeout for accepting a server connect back must of course respect a global timeout. Then the timeleft function is only used by ftp code so it was moved to ftp.c and made static.
2011-12-20FTP: perform active connections non-blockingGokhan Sengun
1- Two new error codes are introduced. CURLE_FTP_ACCEPT_FAILED to be set whenever ACCEPTing fails because of FTP server connected. CURLE_FTP_ACCEPT_TIMEOUT to be set whenever ACCEPTing timeouts. Neither of these errors are considered fatal and control connection remains OK because it could just be a firewall blocking server to connect to the client. 2- One new setopt option was introduced. CURLOPT_ACCEPTTIMEOUT_MS It sets the maximum amount of time FTP client is going to wait for a server to connect. Internal default accept timeout is 60 seconds.
2011-12-13connect.c: fix compiler warning 'enumerated type is mixed with another type'Yang Tse
2011-12-12CURLOPT_INTERFACE: avoid resolving interfaces namesJason Glasgow
Do not try to resolve interfaces names via DNS by recognizing interface names in a few ways. If the interface option argument has a prefix of "if!" then treat the argument as only an interface. Similarly, if the interface argument is the name of an interface (even if it does not have an IP address assigned), treat it as an interface name. Finally, if the interface argument is prefixed by "host!" treat it as a hostname that must be resolved by /etc/hosts or DNS. These changes allow a client using the multi interfaces to avoid blocking on name resolution if the interface loses its IP address or disappears.
2011-12-07Curl_closesocket: clear sock_accepted on closeGokhan Sengun
As a follow-up from commit d5b5f64bce3a8, clear the sock_accepted status when such a socket is closed to avoid a re-used connection to retain the state wrongly. Bug: http://curl.haxx.se/mail/lib-2011-12/0079.html
2011-12-05FTP: close callback fixDaniel Stenberg
Keep track of which sockets that are the result of accept() calls and refuse to call the closesocket callback for those sockets. Test case 596 now verifies that the open socket callback is called the same number of times as the closed socket callback for active FTP connections. Bug: http://curl.haxx.se/mail/lib-2011-12/0018.html Reported by: Gokhan Sengun
2011-12-05FTP: call opensocket callback properlyDaniel Stenberg
When the new socket is created for an active connection, it is now done using the open socket callback. Test case 596 was modified to run fine, although it hides the fact that the close callback is still called too many times, as it also gets called for closing sockets that were created with accept().
2011-12-05Curl_socket: internal replacement for socket()Daniel Stenberg
Moved out into a separate function to work as a "generic" socket() replacement.
2011-10-17singleipconnect: unstick the ipv6-connection booleanDaniel Stenberg
Previously the bit was set before the connection was found working so if it would first fail to an ipv6 address and then connect fine to a IPv4 address the variable would still be TRUE. Reported by: Thomas L. Shinnick Bug: http://curl.haxx.se/bug/view.cgi?id=3421912
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.