summaryrefslogtreecommitdiff
path: root/lib/asyn-thread.c
Commit message (Collapse)AuthorAgeFilesLines
* asyn-thread: make use of Curl_socketpair() where availableDaniel Stenberg2019-10-101-12/+14
|
* asyn-thread: s/AF_LOCAL/AF_UNIX for SolarisDaniel Stenberg2019-09-121-2/+2
| | | | | | Reported-by: Dagobert Michelsen Fixes #4328 Closes #4333
* asyn-thread: issue CURL_POLL_REMOVE before closing socketEric Wong2019-08-111-5/+20
| | | | | | | | | | | | This avoids EBADF errors from EPOLL_CTL_DEL operations in the ephiperfifo.c example. EBADF is dangerous in multi-threaded applications where I rely on epoll_ctl to operate on the same epoll description from different threads. Follow-up to eb9a604f8d7db8 Bug: https://curl.haxx.se/mail/lib-2019-08/0026.html Closes #4211
* timediff: make it 64 bit (if possible) even with 32 bit time_tDaniel Stenberg2019-08-011-3/+4
| | | | | | | ... to make it hold microseconds too. Fixes #4165 Closes #4168
* cleanup: remove the 'numsocks' argument used in many placesDaniel Stenberg2019-07-301-3/+1
| | | | | | | | | It was used (intended) to pass in the size of the 'socks' array that is also passed to these functions, but was rarely actually checked/used and the array is defined to a fixed size of MAX_SOCKSPEREASYHANDLE entries that should be used instead. Closes #4169
* asyn-thread: removed unused variableDaniel Stenberg2019-07-301-2/+1
| | | | | Follow-up to eb9a604f. Mistake caused by me when I edited the commit before push...
* asyn-thread: create a socketpair to wait onamkatyal2019-07-301-11/+65
| | | | Closes #4157
* HTTP3: initial (experimental) supportDaniel Stenberg2019-07-211-1/+2
| | | | | | | | | 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
* threaded-resolver: shutdown the resolver thread without error messageDaniel Stenberg2019-03-011-30/+38
| | | | | | | | | | | | When a transfer is done, the resolver thread will be brought down. That could accidentally generate an error message in the error buffer even though this is not an error situationand the transfer would still return OK. An application that still reads the error buffer could find a "Could not resolve host: [host name]" message there and get confused. Reported-by: Michael Schmid Fixes #3629 Closes #3630
* curl_multi_remove_handle() don't block terminating c-ares requestsBrad Spencer2019-01-071-2/+23
| | | | | | | | | Added Curl_resolver_kill() for all three resolver modes, which only blocks when necessary, along with test 1592 to confirm curl_multi_remove_handle() doesn't block unless it must. Closes #3428 Fixes #3371
* snprintf: renamed and we now only use msnprintf()Daniel Stenberg2018-11-231-2/+2
| | | | | | | | | | | 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-3/+4
| | | | | | | | | | | | | | | | | | | 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
* asyn-thread: Remove unused macroRikard Falkeborn2018-08-091-2/+0
| | | | | | The macro seems to never have been used. Closes #2852
* easy_perform: use *multi_timeout() to get wait timesDaniel Stenberg2018-06-271-3/+3
| | | | | | | | | ... and trim the threaded Curl_resolver_getsock() to return zero millisecond wait times during the first three milliseconds so that localhost or names in the OS resolver cache gets detected and used faster. Closes #2685
* multi: fix memory leak when stopped during name resolveDaniel Stenberg2018-06-161-2/+4
| | | | | | | | | | | | When the application just started the transfer and then stops it while the name resolve in the background thread hasn't completed, we need to wait for the resolve to complete and then cleanup data accordingly. Enabled test 1553 again and added test 1590 to also check when the host name resolves successfully. Detected by OSS-fuzz. Closes #1968
* threaded resolver: track resolver time and set suitable timeout valuesDaniel Stenberg2018-03-241-28/+39
| | | | | | | | | | In order to make curl_multi_timeout() return suitable "sleep" times even when there's no socket to wait for while the name is being resolved in a helper thread. It will increases the timeouts as time passes. Closes #2419
* time: rename Curl_tvnow to Curl_nowDaniel Stenberg2017-10-251-1/+1
| | | | | | | | | | ... 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-1/+2
| | | | | | | | | | | | | | | ... 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
* asyn-thread: Fixed cleanup after OOMDan Fandrich2017-08-291-0/+9
| | | | | | | | | destroy_async_data() assumes that if the flag "done" is not set yet, the thread itself will clean up once the request is complete. But if an error (generally OOM) occurs before the thread even has a chance to start, it will never get a chance to clean up and memory will be leaked. By clearing "done" only just before starting the thread, the correct cleanup sequence will happen in all cases.
* asyn-thread: Improved cleanup after OOM situationsDan Fandrich2017-08-281-3/+7
|
* asyn-thread: Set errno to the proper value ENOMEM in OOM situationDan Fandrich2017-08-281-1/+1
| | | | | This used to be set in some configurations to EAI_MEMORY which is not a valid value for errno and caused Curl_strerror to fail an assertion.
* curl_setup_once: Remove ERRNO/SET_ERRNO macrosJay Satiro2017-07-101-5/+2
| | | | | | | | | | | | 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
* asyn-thread.c: fix unused variable warnings on macOSDaniel Stenberg2017-07-061-13/+14
|
* multi: use a fixed array of timers instead of mallocDaniel Stenberg2017-05-101-2/+2
| | | | | | | | | | ... since the total amount is low this is faster, easier and reduces memory overhead. Also, Curl_expire_done() can now mark an expire timeout as done so that it never times out. Closes #1472
* asyn-thread: fix unused macro warningsMarcel Raad2017-05-071-5/+5
| | | | Don't do anything in this file if CURLRES_THREADED is not defined.
* checksrc: stricter no-space-before-paren enforcementDaniel Stenberg2016-12-131-6/+6
| | | | In order to make the code style more uniform everywhere
* checksrc: white space edits to comply to stricter checksrcDaniel Stenberg2016-11-241-1/+1
|
* checksrc: code style: use 'char *name' styleDaniel Stenberg2016-11-241-3/+3
|
* lib: fix compiler warnings after de4de4e3c7cMarcel Raad2016-11-181-2/+2
| | | | | | | | | Visual C++ now complains about implicitly casting time_t (64-bit) to long (32-bit). Fix this by changing some variables from long to time_t, or explicitly casting to long where the public interface would be affected. Closes #1131
* internals: rename the SessionHandle struct to Curl_easyDaniel Stenberg2016-06-221-5/+5
|
* resolve: enable protocol family logic for synthesized IPv6Luo Jinghua2016-06-071-2/+3
| | | | | | | | | | | | | | - Enable protocol family logic for IPv6 resolves even when support for synthesized addresses is enabled. This is a follow up to the parent commit that added support for synthesized IPv6 addresses from IPv4 on iOS/OS X. The protocol family logic needed for IPv6 was inadvertently excluded if support for synthesized addresses was enabled. Bug: https://github.com/curl/curl/issues/863 Ref: https://github.com/curl/curl/pull/866 Ref: https://github.com/curl/curl/pull/867
* resolve: add support for IPv6 DNS64/NAT64 Networks on OS X + iOSLuo Jinghua2016-06-071-1/+10
| | | | | | | | | Use getaddrinfo() to resolve the IPv4 address literal on iOS/Mac OS X. If the current network interface doesn’t support IPv4, but supports IPv6, NAT64, and DNS64. Closes #866 Fixes #863
* lib: include curl_printf.h as one of the last headersDaniel Stenberg2016-04-291-3/+2
| | | | | | | | | | | | | | | | | | | | curl_printf.h defines printf to curl_mprintf, etc. This can cause problems with external headers which may use __attribute__((format(printf, ...))) markers etc. To avoid that they cause problems with system includes, we include curl_printf.h after any system headers. That makes the three last headers to always be, and we keep them in this order: curl_printf.h curl_memory.h memdebug.h None of them include system headers, they all do funny #defines. Reported-by: David Benjamin Fixes #743
* URLs: change all http:// URLs to https://Daniel Stenberg2016-02-031-1/+1
|
* checksrc: use space after commaDaniel Stenberg2015-03-171-1/+1
|
* free: instead of Curl_safefree()Daniel Stenberg2015-03-161-1/+1
| | | | | | | | | | | | Since we just started make use of free(NULL) in order to simplify code, this change takes it a step further and: - converts lots of Curl_safefree() calls to good old free() - makes Curl_safefree() not check the pointer before free() The (new) rule of thumb is: if you really want a function call that frees a pointer and then assigns it to NULL, then use Curl_safefree(). But we will prefer just using free() from now on.
* Bug #149: Deletion of unnecessary checks before calls of the function "free"Markus Elfring2015-03-161-5/+2
| | | | | | | | | | | The function "free" is documented in the way that no action shall occur for a passed null pointer. It is therefore not needed that a function caller repeats a corresponding check. http://stackoverflow.com/questions/18775608/free-a-null-pointer-anyway-or-check-first This issue was fixed by using the software Coccinelle 1.0.0-rc24. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
* mprintf.h: remove #ifdef CURLDEBUGDaniel Stenberg2015-03-031-5/+3
| | | | | ... and as a consequence, introduce curl_printf.h with that re-define magic instead and make all libcurl code use that instead.
* code/docs: Use correct case for IPv4 and IPv6Steve Holme2014-12-271-1/+1
| | | | | | 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.
* asyn-thread: We prefer 'CURLcode result'Steve Holme2014-12-141-10/+12
|
* threaded-resolver: revert Curl_expire_latest() switchDaniel Stenberg2014-09-231-1/+1
| | | | | | | | | | The switch to using Curl_expire_latest() in commit cacdc27f52b was a mistake and was against the advice even mentioned in that commit. The comparison in asyn-thread.c:Curl_resolver_is_resolved() makes Curl_expire() the suitable function to use. Bug: http://curl.haxx.se/bug/view.cgi?id=1426 Reported-By: graysky
* 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
* resolve: cache lookup for async resolversMichael Wallner2014-08-311-15/+53
| | | | | | | | | | While waiting for a host resolve, check if the host cache may have gotten the name already (by someone else), for when the same name is resolved by several simultanoues requests. The resolver thread occasionally gets stuck in getaddrinfo() when the DNS or anything else is crappy or slow, so when a host is found in the DNS cache, leave the thread alone and let itself cleanup the mess.
* bits.close: Fixed compilation warningSteve Holme2014-05-221-0/+1
| | | | warning: implicit declaration of function 'connclose'
* bits.close: introduce connection close trackingDaniel Stenberg2014-05-221-1/+1
| | | | | | | 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.
* threaded-resolver: never use NULL hints with getaddrinfoDaniel Stenberg2014-01-101-2/+2
| | | | | | | | | | | | | | | | | | | | | The net effect of this bug as it appeared to users, would be that libcurl would timeout in the connect phase. When disabling IPv6 use but still using getaddrinfo, libcurl would wrongly not init the "hints" struct field in init_thread_sync() which would subsequently lead to a getaddrinfo() invoke with a zeroed hints with ai_socktype set to 0 instead of SOCK_STREAM. This would lead to different behaviors on different platforms but basically incorrect output. This code was introduced in 483ff1ca75cbea, released in curl 7.20.0. This bug became a problem now due to the happy eyeballs code and how libcurl now traverses the getaddrinfo() results differently. Bug: http://curl.haxx.se/mail/lib-2014-01/0061.html Reported-by: Fabian Frank Debugged-by: Fabian Frank
* dns: fix compilation with MinGW from commit df69440d05f113Steve Holme2013-09-171-2/+2
| | | | | | Avoid 'interface' literal that some MinGW versions define as a macro Additionally, corrected some very, very minor coding style errors.
* libcurl: New options to bind DNS to local interfaces or IP addressesKim Vandry2013-09-121-0/+24
|
* NI_MAXSERV: remove all use of itDaniel Stenberg2013-09-101-2/+2
| | | | | | | | | | | Solaris with the SunStudio Compiler is reportedly missing this define, but as we're using it without any good reason on all the places it was used I've now instead switched to just use sensible buffer sizes that fit a 32 bit decimal number. Which also happens to be smaller than the common NI_MAXSERV value which is 32 on most machines. Bug: http://curl.haxx.se/bug/view.cgi?id=1277 Reported-by: D.Flinkmann
* resolver_error: remove wrong error message outputDaniel Stenberg2013-02-181-48/+2
| | | | | | | | The attempt to use gai_strerror() or alternative function didn't work as the 'sock_error' field didn't contain the proper error code. But since this hasn't been reported and thus isn't really a big deal I decided to just scrap the whole attempt to output the detailed resolver error and instead remain with just stating that the resolving of the name failed.