summaryrefslogtreecommitdiff
path: root/lib/connect.c
Commit message (Collapse)AuthorAgeFilesLines
* lib: fix compiler warnings with `CURL_DISABLE_VERBOSE_STRINGS`Marcel Raad2020-01-031-6/+6
| | | | Closes https://github.com/curl/curl/pull/4775
* HTTP3: fix Windows buildJavier Blazquez2019-10-281-0/+5
| | | | | | | | | | | | | The ngtcp2 QUIC backend was using the MSG_DONTWAIT flag for send/recv in order to perform nonblocking operations. On Windows this flag does not exist. Instead, the socket must be set to nonblocking mode via ioctlsocket. This change sets the nonblocking flag on UDP sockets used for QUIC on all platforms so the use of MSG_DONTWAIT is not needed. Fixes #4531 Closes #4532
* connect: silence sign-compare warningMarcel Raad2019-10-131-1/+1
| | | | | | | With MinGW-w64 using WinSock, `curl_socklen_t` is signed, while the result of `sizeof` is unsigned. Closes https://github.com/curl/curl/pull/4483
* connect: return CURLE_OPERATION_TIMEDOUT for errno == ETIMEDOUTDaniel Stenberg2019-10-091-0/+8
| | | | | | | | | | | Previosly all connect() failures would return CURLE_COULDNT_CONNECT, no matter what errno said. This makes for example --retry work on these transfer failures. Reported-by: Nathaniel J. Smith Fixes #4461 Clsoes #4462
* cleanup: move functions out of url.c and make them staticDaniel Stenberg2019-09-031-1/+54
| | | | Closes #4289
* Curl_addr2string: take an addrlen argument tooDaniel Stenberg2019-08-311-11/+19
| | | | | | | | | | | This allows the function to figure out if a unix domain socket has a file name or not associated with it! When a socket is created with socketpair(), as done in the fuzzer testing, the path struct member is uninitialized and must not be accessed. Bug: https://crbug.com/oss-fuzz/16699 Closes #4283
* connect: connections are persistent by default for HTTP/3Daniel Stenberg2019-08-141-0/+3
|
* ngtcp2: do QUIC connections happy-eyeballs friendlyDaniel Stenberg2019-08-141-14/+33
|
* http3: make connection reuse workDaniel Stenberg2019-08-091-11/+7
| | | | Closes #4204
* timediff: make it 64 bit (if possible) even with 32 bit time_tDaniel Stenberg2019-08-011-5/+5
| | | | | | | ... to make it hold microseconds too. Fixes #4165 Closes #4168
* HTTP3: initial (experimental) supportDaniel Stenberg2019-07-211-6/+17
| | | | | | | | | USe configure --with-ngtcp2 or --with-quiche Using either option will enable a HTTP3 build. Co-authored-by: Alessandro Ghedini <alessandro@ghedini.me> Closes #3500
* bindlocal: detect and avoid IP version mismatches in bind()Daniel Stenberg2019-06-101-0/+5
| | | | | | Reported-by: Alex Grebenschikov Fixes #3993 Closes #4002
* udpateconninfo: mark variable unusedDaniel Gustafsson2019-05-211-0/+2
| | | | | | | | | | When compiling without getpeername() or getsockname(), the sockfd paramter to Curl_udpateconninfo() became unused after commit e91e481612 added ifdef guards. Closes #3910 Fixes https://curl.haxx.se/dev/log.cgi?id=20190520172441-32196 Reviewed-by: Marcel Raad, Daniel Stenberg
* lib: reduce variable scopesMarcel Raad2019-05-201-3/+2
| | | | | | Fixes Codacy/CppCheck warnings. Closes https://github.com/curl/curl/pull/3872
* libcurl: #ifdef away more code for disabled features/protocolsDaniel Stenberg2019-05-171-9/+14
|
* doh: disable DOH for the cases it doesn't workDaniel Stenberg2019-05-111-1/+1
| | | | | | | | | | Due to limitations in Curl_resolver_wait_resolv(), it doesn't work for DOH resolves. This fix disables DOH for those. Limitation added to KNOWN_BUGS. Fixes #3850 Closes #3857
* singleipconnect: show port in the verbose "Trying ..." messageDaniel Stenberg2019-04-131-1/+1
| | | | To aid debugging better.
* urldata: convert bools to bitfields and move to endDaniel Stenberg2019-02-271-1/+1
| | | | | | | | | | | | This allows the compiler to pack and align the structs better in memory. For a rather feature-complete build on x86_64 Linux, gcc 8.1.2 makes the Curl_easy struct 4.9% smaller. From 6312 bytes to 6000. Removed an unused struct field. No functionality changes. Closes #3610
* strerror: make the strerror function use local buffersDaniel Stenberg2019-02-261-17/+28
| | | | | | | | | | | | | | | | Instead of using a fixed 256 byte buffer in the connectdata struct. In my build, this reduces the size of the connectdata struct by 11.8%, from 2160 to 1904 bytes with no functionality or performance loss. This also fixes a bug in schannel's Curl_verify_certificate where it called Curl_sspi_strerror when it should have called Curl_strerror for string from GetLastError. the only effect would have been no text or the wrong text being shown for the error. Co-authored-by: Jay Satiro Closes #3612
* cleanup: make local functions staticDaniel Stenberg2019-02-101-11/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | urlapi: turn three local-only functions into statics conncache: make conncache_find_first_connection static multi: make detach_connnection static connect: make getaddressinfo static curl_ntlm_core: make hmac_md5 static http2: make two functions static http: make http_setup_conn static connect: make tcpnodelay static tests: make UNITTEST a thing to mark functions with, so they can be static for normal builds and non-static for unit test builds ... and mark Curl_shuffle_addr accordingly. url: make up_free static setopt: make vsetopt static curl_endian: make write32_le static rtsp: make rtsp_connisdead static warnless: remove unused functions memdebug: remove one unused function, made another static
* connect: fix building for recent versions of MinixSevan Janiyan2018-11-291-1/+1
| | | | | | | | EBADIOCTL doesn't exist on more recent Minix. There have also been substantial changes to the network stack. Fixes build on Minix 3.4rc Closes https://github.com/curl/curl/pull/3323
* snprintf: renamed and we now only use msnprintf()Daniel Stenberg2018-11-231-1/+1
| | | | | | | | | | | The function does not return the same value as snprintf() normally does, so readers may be mislead into thinking the code works differently than it actually does. A different function name makes this easier to detect. Reported-by: Tomas Hoger Assisted-by: Daniel Gustafsson Fixes #3296 Closes #3297
* ares: remove fd from multi fd set when ares is about to close the fdRomain Fliedel2018-11-201-2/+2
| | | | | | | | | | | | | | | | | | | When using c-ares for asyn dns, the dns socket fd was silently closed by c-ares without curl being aware. curl would then 'realize' the fd has been removed at next call of Curl_resolver_getsock, and only then notify the CURLMOPT_SOCKETFUNCTION to remove fd from its poll set with CURL_POLL_REMOVE. At this point the fd is already closed. By using ares socket state callback (ARES_OPT_SOCK_STATE_CB), this patch allows curl to be notified that the fd is not longer needed for neither for write nor read. At this point by calling Curl_multi_closed we are able to notify multi with CURL_POLL_REMOVE before the fd is actually closed by ares. In asyn-ares.c Curl_resolver_duphandle we can't use ares_dup anymore since it does not allow passing a different sock_state_cb_data Closes #3238
* url: fix dangling conn->data pointerDaniel Stenberg2018-06-211-2/+4
| | | | | | | | | | | By masking sure to use the *current* easy handle with extracted connections from the cache, and make sure to NULLify the ->data pointer when the connection is put into the cache to make this mistake easier to detect in the future. Reported-by: Will Dietz Fixes #2669 Closes #2672
* cppcheck: fix warningsMarian Klymov2018-06-111-5/+1
| | | | | | | | | | | | | - Get rid of variable that was generating false positive warning (unitialized) - Fix issues in tests - Reduce scope of several variables all over etc Closes #2631
* url: Add option CURLOPT_HAPPY_EYEBALLS_TIMEOUTAnders Bakken2018-02-201-2/+4
| | | | | | | | | | | | | | - Add new option CURLOPT_HAPPY_EYEBALLS_TIMEOUT to set libcurl's happy eyeball timeout value. - Add new optval macro CURL_HET_DEFAULT to represent the default happy eyeballs timeout value (currently 200 ms). - Add new tool option --happy-eyeballs-timeout-ms to expose CURLOPT_HAPPY_EYEBALLS_TIMEOUT. The -ms suffix is used because the other -timeout options in the tool expect seconds not milliseconds. Closes https://github.com/curl/curl/pull/2260
* CURLOPT_RESOLVE: Add support for multiple IP addresses per entryAnders Bakken2018-02-201-8/+8
| | | | | | | This enables users to preresolve but still take advantage of happy eyeballs and trying multiple addresses if some are not connecting. Ref: https://github.com/curl/curl/pull/2260
* TODO fixed: Detect when called from within callbacksBjörn Stenberg2018-02-151-2/+11
| | | | Closes #2302
* connect: add support for new TCP Fast Open API on LinuxAlessandro Ghedini2017-11-241-3/+16
| | | | | | | | | | | The new API added in Linux 4.11 only requires setting a socket option before connecting, without the whole sento() machinery. Notably, this makes it possible to use TFO with SSL connections on Linux as well, without the need to mess around with OpenSSL (or whatever other SSL library) internals. Closes #2056
* connect: improve the bind error messageJay Satiro2017-11-231-0/+4
| | | | | | | | | | eg consider a non-existent interface eth8, curl --interface eth8 Before: curl: (45) Could not resolve host: eth8 After: curl: (45) Couldn't bind to 'eth8' Bug: https://github.com/curl/curl/issues/2104 Reported-by: Alfonso Martone
* macOS: Fix missing connectx function with Xcode version older than 9.0Pavol Markovic2017-11-151-5/+8
| | | | | | | | | | | The previous fix https://github.com/curl/curl/pull/1788 worked just for Xcode 9. This commit extends the fix to older Xcode versions effectively by not using connectx function. Fixes https://github.com/curl/curl/issues/1330 Fixes https://github.com/curl/curl/issues/2080 Closes https://github.com/curl/curl/pull/1336 Closes #2082
* connect.c: remove executable bit on fileOrgad Shaneh2017-11-121-0/+0
| | | | Closes #2071
* --interface: add support for Linux VRFLuca Boccassi2017-11-091-24/+28
| | | | | | | | | | | | | The --interface command (CURLOPT_INTERFACE option) already uses SO_BINDTODEVICE on Linux, but it tries to parse it as an interface or IP address first, which fails in case the user passes a VRF. Try to use the socket option immediately and parse it as a fallback instead. Update the documentation to mention this feature, and that it requires the binary to be ran by root or with CAP_NET_RAW capabilities for this to work. Closes #2024
* share: add support for sharing the connection cacheDaniel Stenberg2017-11-091-1/+1
|
* connect: store IPv6 connection status after valid connectionDaniel Stenberg2017-11-091-4/+3
| | | | | | | | ... previously it would store it already in the happy eyeballs stage which could lead to the IPv6 bit being set for an IPv4 connection, leading to curl not wanting to do EPSV=>PASV for FTP transfers. Closes #2053
* timeleft: made two more users of Curl_timeleft use timediff_tDaniel Stenberg2017-10-291-1/+1
|
* Curl_timeleft: change return type to timediff_tDaniel Stenberg2017-10-281-5/+5
| | | | | | | | returning 'time_t' is problematic when that type is unsigned and we return values less than zero to signal "already expired", used in several places in the code. Closes #2021
* time: rename Curl_tvnow to Curl_nowDaniel Stenberg2017-10-251-4/+4
| | | | | | | | | | ... since the 'tv' stood for timeval and this function does not return a timeval struct anymore. Also, cleaned up the Curl_timediff*() functions to avoid typecasts and clean up the descriptive comments. Closes #2011
* timediff: return timediff_t from the time diff functionsDaniel Stenberg2017-10-251-4/+4
| | | | | | | | | | | | | | | ... to cater for systems with unsigned time_t variables. - Renamed the functions to curlx_timediff and Curl_timediff_us. - Added overflow protection for both of them in either direction for both 32 bit and 64 bit time_ts - Reprefixed the curlx_time functions to use Curl_* Reported-by: Peter Piekarski Fixes #2004 Closes #2005
* connect: fix race condition with happy eyeballs timeoutAnders Bakken2017-09-291-1/+1
| | | | | | | | | | | The timer should be started after conn->connecttime is set. Otherwise the timer could expire without this condition being true: /* should we try another protocol family? */ if(i == 0 && conn->tempaddr[1] == NULL && curlx_tvdiff(now, conn->connecttime) >= HAPPY_EYEBALLS_TIMEOUT) { Ref: #1928
* code style: use spaces around plusesDaniel Stenberg2017-09-111-1/+1
|
* code style: use spaces around equals signsDaniel Stenberg2017-09-111-4/+4
|
* configure: check for __builtin_available() availability (#1788)Nick Zitzmann2017-08-161-10/+19
| | | | | | | This change does two things: 1. It un-breaks the build in Xcode 9.0. (Xcode 9.0 is currently failing trying to compile connectx() in lib/connect.c.) 2. It finally weak-links the connectx() function, and falls back on connect() when run on older operating systems.
* timeval: struct curltime is a struct timeval replacementDaniel Stenberg2017-07-281-4/+4
| | | | | | | | | ... to make all libcurl internals able to use the same data types for the struct members. The timeval struct differs subtly on several platforms so it makes it cumbersome to use everywhere. Ref: #1652 Closes #1693
* curl_setup_once: Remove ERRNO/SET_ERRNO macrosJay Satiro2017-07-101-12/+8
| | | | | | | | | | | | Prior to this change (SET_)ERRNO mapped to GetLastError/SetLastError for Win32 and regular errno otherwise. I reviewed the code and found no justifiable reason for conflating errno on WIN32 with GetLastError/SetLastError. All Win32 CRTs support errno, and any Win32 multithreaded CRT supports thread-local errno. Fixes https://github.com/curl/curl/issues/895 Closes https://github.com/curl/curl/pull/1589
* configure: remove checks for 5 functions never usedDaniel Stenberg2017-07-041-13/+0
| | | | | | fork, getprotobyname, inet_addr, perror, uname closes #1638
* expire: remove Curl_expire_latest()Daniel Stenberg2017-06-081-1/+1
| | | | | | | | | | | | | | | | | With the introduction of expire IDs and the fact that existing timers can be removed now and thus never expire, the concept with adding a "latest" timer is not working anymore as it risks to not expire at all. So, to be certain the timers actually are in line and will expire, the plain Curl_expire() needs to be used. The _latest() function was added as a sort of shortcut in the past that's quite simply not necessary anymore. Follow-up to 31b39c40cf90 Reported-by: Paul Harris Closes #1555
* multi: assign IDs to all timers and make each timer singletonDaniel Stenberg2017-05-101-3/+3
| | | | | | | A) reduces the timeout lists drastically B) prevents a lot of superfluous loops for timers that expires "in vain" when it has actually already been extended to fire later on
* connect: fix unreferenced parameter warningMarcel Raad2017-03-301-1/+1
| | | | | When CURL_DISABLE_VERBOSE_STRINGS is defined, the reason parameter in Curl_conncontrol is not used as the infof macro expands to nothing.
* Improve code readbilitySylvestre Ledru2017-03-131-2/+1
| | | | | | ... by removing the else branch after a return, break or continue. Closes #1310