summaryrefslogtreecommitdiff
path: root/lib/asyn-thread.c
Commit message (Collapse)AuthorAgeFilesLines
* curl.se: new homeDaniel Stenberg2020-11-041-1/+1
| | | | Closes #6172
* build: disable more code/data when built without proxy supportDaniel Stenberg2020-05-301-1/+4
| | | | | | Added build to travis to verify Closes #5466
* timeouts: change millisecond timeouts to timediff_t from time_tDaniel Stenberg2020-05-301-5/+5
| | | | | | | For millisecond timers we like timediff_t better. Also, time_t can be unsigned so returning a negative value doesn't work then. Closes #5479
* source cleanup: remove all custom typedef structsDaniel Stenberg2020-05-151-9/+9
| | | | | | | | | | | - Stick to a single unified way to use structs - Make checksrc complain on 'typedef struct {' - Allow them in tests, public headers and examples - Let MD4_CTX, MD5_CTX, and SHA256_CTX typedefs remain as they actually typedef different types/structs depending on build conditions. Closes #5338
* checksrc: enhance the ASTERISKSPACE and update code accordinglyDaniel Stenberg2020-05-141-3/+3
| | | | | | | | Fine: "struct hello *world" Not fine: "struct hello* world" (and variations) Closes #5386
* asyn-*: remove support for never-used NULL entry pointersDaniel Stenberg2020-05-031-4/+6
| | | | | | | ... and instead convert those to asserts to make sure they are truly never NULL. Closes #5324
* asyn-thread: fix cppcheck warningJay Satiro2020-05-021-2/+4
| | | | | | | | | | | | | | | - Check for NULL entry parameter before attempting to deref entry in Curl_resolver_is_resolved, like is already done in asyn-ares. This is to silence cppcheck which does not seem to understand that asyn-ares and asyn-thread have separate Curl_resolver_is_resolved and those units are mutually exclusive. Prior to this change it warned of a scenario where asyn-thread's Curl_resolver_is_resolved is called with a NULL entry from asyn-ares, but that couldn't happen. Reported-by: rl1987@users.noreply.github.com Fixes https://github.com/curl/curl/issues/5326
* asyn-thread: remove dead codeJay Satiro2020-02-091-3/+0
|
* global_init: move the IPv6 works status bool to multi handleDaniel Stenberg2020-01-281-1/+1
| | | | | | | | | Previously it was stored in a global state which contributed to curl_global_init's thread unsafety. This boolean is now instead figured out in curl_multi_init() and stored in the multi handle. Less effective, but thread safe. Closes #4851
* fix: Copyright year out of date, should be 2020Daniel Stenberg2020-01-101-1/+1
| | | | Follow-up to 875314ed0bf3b
* hostip: move code to resolve IP address literals to `Curl_resolv`Marcel Raad2020-01-101-35/+0
| | | | | | | | | | | | | | | | The code was duplicated in the various resolver backends. Also, it was called after the call to `Curl_ipvalid`, which matters in case of `CURLRES_IPV4` when called from `connect.c:bindlocal`. This caused test 1048 to fail on classic MinGW. The code ignores `conn->ip_version` as done previously in the individual resolver backends. Move the call to the `resolver_start` callback up to appease test 655, which wants it to be called also for literal addresses. Closes https://github.com/curl/curl/pull/4798
* lib: remove erroneous +x file permission on some c filesXiang Xiao2019-12-271-0/+0
| | | | | | Modified by commit eb9a604 accidentally. Closes https://github.com/curl/curl/pull/4756
* curl_setup: disable IPv6 resolver without `getaddrinfo`Marcel Raad2019-12-031-2/+12
| | | | | | | | | | Also, use `CURLRES_IPV6` only for actual DNS resolution, not for IPv6 address support. This makes it possible to connect to IPv6 literals by setting `ENABLE_IPV6` even without `getaddrinfo` support. It also fixes the CMake build when using the synchronous resolver without `getaddrinfo` support. Closes https://github.com/curl/curl/pull/4662
* 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>