summaryrefslogtreecommitdiff
path: root/lib/select.c
Commit message (Collapse)AuthorAgeFilesLines
* select: stop treating POLLRDBAND as an errorDaniel Stenberg2023-02-231-2/+2
| | | | | | | | | POLLRDBAND does not seem to be an general error and on Windows the value for POLLIN is 768 and the value for POLLRDBAND is 512. Fixes #10501 Reported-by: opensslonzos-github on github Closes #10592
* copyright: update all copyright lines and remove year rangesDaniel Stenberg2023-01-031-1/+1
| | | | | | | | | | | | - they are mostly pointless in all major jurisdictions - many big corporations and projects already don't use them - saves us from pointless churn - git keeps history for us - the year range is kept in COPYING checksrc is updated to allow non-year using copyright statements Closes #10205
* select: do not return fatal error on EINTR from poll()Thomas Weißschuh2022-07-041-1/+5
| | | | | | | | | | | | | The same was done for select() in 5912da25 but poll() was missed. Bug: https://bugs.archlinux.org/task/75201 Reported-by: Alexandre Bury (gyscos at archlinux) Ref: https://github.com/curl/curl/issues/8921 Ref: https://github.com/curl/curl/pull/8961 Ref: https://github.com/curl/curl/commit/5912da25#r77584294 Closes https://github.com/curl/curl/pull/9091
* copyright: make repository REUSE compliantmax.mehl2022-06-131-0/+2
| | | | | | | | | | | Add licensing and copyright information for all files in this repository. This either happens in the file itself as a comment header or in the file `.reuse/dep5`. This commit also adds a Github workflow to check pull requests and adapts copyright.pl to the changes. Closes #8869
* select: return error from "lethal" poll/select errorsDaniel Stenberg2022-06-081-1/+5
| | | | | | | | | Adds two new error codes: CURLE_UNRECOVERABLE_POLL and CURLM_UNRECOVERABLE_POLL one each for the easy and the multi interfaces. Reported-by: Harry Sintonen Fixes #8921 Closes #8961
* timediff.[ch]: add curlx helper functions for timeval conversionsMarc Hoersken2022-04-171-58/+3
| | | | | | | | | | | Also move timediff_t definitions from timeval.h to timediff.h and then make timeval.h include the new standalone-capable timediff.h. Reviewed-by: Jay Satiro Reviewed-by: Daniel Stenberg Supersedes #5888 Closes #8595
* TPF: drop supportDaniel Stenberg2022-02-041-20/+0
| | | | | | | | | There has been no TPF related changes done since September 2010 (commit 7e1a45e224e57) and since this is a platform that is relatively different than many others (== needs attention), I draw the conclusion that this build is broken since a long time. Closes #8378
* vxworks: drop supportDaniel Stenberg2022-02-011-4/+0
| | | | | | | No changes or fixes in vxworks related code since 2009 leads me to believe that this doesn't work anymore. Closes #8362
* misc: remove BeOS code and referencesDaniel Stenberg2022-01-171-6/+1
| | | | | | | There has not been a mention of this OS in any commit since December 2004 (58f4af7973e3d2). The OS is also long gone. Closes #8288
* lib: fixing comment spelling typos in lib filesEddie Lumpkin2021-10-221-1/+1
| | | | | Closes #7894 Signed-off-by: ewlumpkin <ewlumpkin@gmail.com>
* tidy-up: make conditional checks more consistentDaniel Stenberg2021-04-221-1/+1
| | | | | | ... remove '== NULL' and '!= 0' Closes #6912
* select: convert Curl_select() to private static functionDaniel Stenberg2021-01-271-7/+10
| | | | | | | | | | The old function should not be used anywhere anymore (the only remaining gskit use has to be fixed to instead use Curl_poll or none at all). The static function version is now called our_select() and is only built if necessary. Closes #6531
* curl.se: new homeDaniel Stenberg2020-11-041-1/+1
| | | | Closes #6172
* select: align poll emulation to return all relevant eventsMarc Hoersken2020-09-021-8/+20
| | | | | | | | | | | | | | The poll emulation via select already consumes POLLRDNORM, POLLWRNORM and POLLRDBAND as input events. Therefore it should also return them as output events if signaled. Also fix indentation in input event handling block. Assisted-by: Jay Satiro Reviewed-by: Daniel Stenberg Replaces #5852 Closes #5883
* select: simplify return code handling for poll and selectMarc Hoersken2020-08-291-24/+13
| | | | | | | | | | | | | poll and select already return -1 on error according to POSIX, so there is no need to perform a <0 to -1 conversion in code. Also we can just use one check with <= 0 on the return code. Assisted-by: Daniel Stenberg Reviewed-by: Jay Satiro Replaces #5852 Closes #5880
* select: reduce duplication of Curl_poll in Curl_socket_checkMarc Hoersken2020-08-251-90/+16
| | | | | | | | | | | Change Curl_socket_check to use select-fallback in Curl_poll instead of implementing it in Curl_socket_check and Curl_poll. Reviewed-by: Daniel Stenberg Reviewed-by: Jay Satiro Replaces #5262 and #5492 Closes #5707
* select: fix poll-based check not detecting connect failureMarc Hoersken2020-08-251-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | This commit changes Curl_socket_check to use POLLPRI to check for connect failure on the write socket, because POLLPRI maps to fds_err. This is in line with select(2). The select-based socket check correctly checks for connect failures by adding the write socket also to fds_err. The poll-based implementation (which internally can itself fallback to select again) did not previously check for connect failure by using POLLPRI with the write socket. See the follow up commit to this for more information. This commit makes sure connect failures can be detected and handled if HAVE_POLL_FINE is defined, eg. on msys2-devel. Reviewed-by: Daniel Stenberg Reviewed-by: Jay Satiro Replaces #5509 Prepares #5707
* select: remove the unused ELAPSED_MS() macroDaniel Stenberg2020-06-181-3/+0
| | | | Closes #5573
* select: always use Sleep in Curl_wait_ms on Win32Marc Hoersken2020-06-011-16/+4
| | | | | | | | | | | Since Win32 almost always will also have USE_WINSOCK, we can reduce complexity and always use Sleep there. Assisted-by: Jay Satiro Reviewed-by: Daniel Stenberg Follow up to #5343 Closes #5489
* select: add overflow checks for timeval conversionsMarc Hoersken2020-05-301-4/+59
| | | | | | | | | | | | Using time_t and suseconds_t if suseconds_t is available, long on Windows (maybe others in the future) and int elsewhere. Also handle case of ULONG_MAX being greater or equal to INFINITE. Assisted-by: Jay Satiro Reviewed-by: Daniel Stenberg Part of #5343
* select: use timediff_t instead of time_t and int for timeout_msMarc Hoersken2020-05-301-49/+36
| | | | | | | | | | | | | Make all functions in select.[ch] take timeout_ms as timediff_t which should always be large enough and signed on all platforms to take all possible timeout values and avoid type conversions. Reviewed-by: Jay Satiro Reviewed-by: Daniel Stenberg Replaces #5107 and partially #5262 Related to #5240 and #5286 Closes #5343
* select: fix overflow protection in Curl_socket_checkJay Satiro2020-05-021-3/+10
| | | | | | | | | Follow-up to a96c752 which changed the timeout_ms type from time_t to timediff_t. Ref: https://github.com/curl/curl/pull/5240 Closes https://github.com/curl/curl/pull/5286
* select: make Curl_socket_check take timediff_t timeoutDaniel Stenberg2020-04-231-2/+2
| | | | | | | | | | Coverity found CID 1461718: Integer handling issues (CONSTANT_EXPRESSION_RESULT) "timeout_ms > 9223372036854775807L" is always false regardless of the values of its operands. This occurs as the logical second operand of "||". Closes #5240
* build: fixed build for systems with select() in unistd.hHarry Sintonen2020-03-311-0/+2
| | | | Closes #5169
* select: add 'timeout_ms' wrap-around precaution to Curl_selectMarc Hoersken2020-03-151-0/+6
|
* select: fix 'pending_ms' is assigned a value that is never usedMarc Hoersken2020-03-151-5/+5
| | | | Detected by Codacy
* select: move duplicate select preparation code into Curl_selectMarc Hoersken2020-03-151-81/+83
| | | | | | Reviewed by Daniel Stenberg Reviewed by Marcel Raad Closes #5078
* global_init: assume the EINTR bit by defaultDaniel Stenberg2020-01-261-151/+64
| | | | | | | | | | | | - Removed from global_init since it isn't thread-safe. The symbol will still remain to not break compiles, it just won't have any effect going forward. - make the internals NOT loop on EINTR (the opposite from previously). It only risks returning from the select/poll/wait functions early, and that should be risk-free. Closes #4840
* copyrights: fix copyright year rangeDaniel Stenberg2019-11-081-1/+1
| | | | | | | | .. because checksrc's copyright year check stopped working. Ref: https://github.com/curl/curl/pull/4547 Closes https://github.com/curl/curl/pull/4549
* cppcheck: fix warningsMarian Klymov2018-06-111-3/+5
| | | | | | | | | | | | | - 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
* select: update commentsDaniel Stenberg2017-10-301-2/+2
| | | | s/curlx_tvnow/Curl_now
* 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
* timeval: struct curltime is a struct timeval replacementDaniel Stenberg2017-07-281-5/+5
| | | | | | | | | ... 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
* select: use correct SIZEOF_ constantMarcel Raad2017-03-301-1/+1
| | | | | | | | | | | At least under Windows, there is no SIZEOF_LONG, so it evaluates to 0 even though sizeof(int) == sizeof(long). This should probably have been CURL_SIZEOF_LONG, but the type of timeout_ms changed from long to time_t anyway. This triggered MSVC warning C4668 about implicitly replacing undefined macros with '0'. Closes https://github.com/curl/curl/pull/1362
* spelling fixesklemens2017-03-261-3/+3
| | | | Closes #1356
* lib: fix compiler warnings after de4de4e3c7cMarcel Raad2016-11-181-1/+1
| | | | | | | | | 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
* select: switch to macros in uppercaseDaniel Stenberg2016-10-181-1/+1
| | | | | | | | | | Curl_select_ready() was the former API that was replaced with Curl_select_check() a while back and the former arg setup was provided with a define (in order to leave existing code unmodified). Now we instead offer SOCKET_READABLE and SOCKET_WRITABLE for the most common shortcuts where only one socket is checked. They're also more visibly macros.
* select: use more proper macro-looking namesDaniel Stenberg2016-10-181-14/+13
| | | | | ... so that it becomes more obvious in the code what is what. Also added a typecast for one of the calculations.
* Curl_socket_check: add extra check to avoid integer overflowDaniel Stenberg2016-10-181-0/+6
|
* URLs: change all http:// URLs to https://Daniel Stenberg2016-02-031-1/+1
|
* lwip: Fix compatibility issues with later versionsGisle Vanem2015-12-071-10/+10
| | | | | | | | | | | | | | | | | | | | | | The name of the header guard in lwIP's <lwip/opt.h> has changed from '__LWIP_OPT_H__' to 'LWIP_HDR_OPT_H' (bug #35874 in May 2015). Other fixes: - In curl_setup.h, the problem with an old PSDK doesn't apply if lwIP is used. - In memdebug.h, the 'socket' should be undefined first due to lwIP's lwip_socket() macro. - In curl_addrinfo.c lwIP's getaddrinfo() + freeaddrinfo() macros need special handling because they were undef'ed in memdebug.h. - In select.c we can't use preprocessor conditionals inside select if MSVC and select is a macro, as it is with lwIP. http://curl.haxx.se/mail/lib-2015-12/0023.html http://curl.haxx.se/mail/lib-2015-12/0024.html
* checksrc: use space after commaDaniel Stenberg2015-03-171-2/+2
|
* checksrc: use space before paren in "return (expr);"Daniel Stenberg2015-03-171-2/+2
|
* select.c: fix compilation for VxWorksDaniel Stenberg2014-11-251-0/+4
| | | | | Reported-by: Brian Bug: http://curl.haxx.se/bug/view.cgi?id=1455
* Curl_poll + Curl_wait_ms: fix timeout return valuePeter Wang2014-08-111-3/+9
| | | | | | | | | Curl_poll and Curl_wait_ms require the fix applied to Curl_socket_check in commits b61e8b8 and c771968: When poll or select are interrupted and coincides with the timeout elapsing, the functions return -1 indicating an error instead of 0 for the timeout.
* select: with winsock, avoid passing unsupported arguments to select()Brad Spencer2014-05-271-3/+55
| | | | | | | | | | | | | | | | "Any two of the parameters, readfds, writefds, or exceptfds, can be given as null. At least one must be non-null, and any non-null descriptor set must contain at least one handle to a socket." http://msdn.microsoft.com/en-ca/library/windows/desktop/ms740141(v=vs.85).aspx When using select(), cURL doesn't adhere to this (WinSock-specific) rule, and can ask to monitor empty fd_sets, which leads to select() returning WSAEINVAL (i.e. EINVAL) and connections failing in mysterious ways as a result (at least when using the curl_multi_socket_action() interface). Bug: http://curl.haxx.se/mail/lib-2014-05/0278.html
* curl_global_init: accept the CURL_GLOBAL_ACK_EINTR flagZdenek Pavlas2013-03-121-15/+2
| | | | | | | | | The flag can be used in pycurl-based applications where using the multi interface would not be acceptable because of the performance lost caused by implementing the select() loop in python. Bug: http://curl.haxx.se/bug/view.cgi?id=1168 Downstream Bug: https://bugzilla.redhat.com/919127
* build: fix circular header inclusion with other packagesYang Tse2013-01-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit renames lib/setup.h to lib/curl_setup.h and renames lib/setup_once.h to lib/curl_setup_once.h. Removes the need and usage of a header inclusion guard foreign to libcurl. [1] Removes the need and presence of an alarming notice we carried in old setup_once.h [2] ---------------------------------------- 1 - lib/setup_once.h used __SETUP_ONCE_H macro as header inclusion guard up to commit ec691ca3 which changed this to HEADER_CURL_SETUP_ONCE_H, this single inclusion guard is enough to ensure that inclusion of lib/setup_once.h done from lib/setup.h is only done once. Additionally lib/setup.h has always used __SETUP_ONCE_H macro to protect inclusion of setup_once.h even after commit ec691ca3, this was to avoid a circular header inclusion triggered when building a c-ares enabled version with c-ares sources available which also has a setup_once.h header. Commit ec691ca3 exposes the real nature of __SETUP_ONCE_H usage in lib/setup.h, it is a header inclusion guard foreign to libcurl belonging to c-ares's setup_once.h The renaming this commit does, fixes the circular header inclusion, and as such removes the need and usage of a header inclusion guard foreign to libcurl. Macro __SETUP_ONCE_H no longer used in libcurl. 2 - Due to the circular interdependency of old lib/setup_once.h and the c-ares setup_once.h header, old file lib/setup_once.h has carried back from 2006 up to now days an alarming and prominent notice about the need of keeping libcurl's and c-ares's setup_once.h in sync. Given that this commit fixes the circular interdependency, the need and presence of mentioned notice is removed. All mentioned interdependencies come back from now old days when the c-ares project lived inside a curl subdirectory. This commit removes last traces of such fact.
* Revert changes relative to lib/*.[ch] recent renamingYang Tse2013-01-061-0/+529
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts renaming and usage of lib/*.h header files done 28-12-2012, reverting 2 commits: f871de0... build: make use of 76 lib/*.h renamed files ffd8e12... build: rename 76 lib/*.h files This also reverts removal of redundant include guard (redundant thanks to changes in above commits) done 2-12-2013, reverting 1 commit: c087374... curl_setup.h: remove redundant include guard This also reverts renaming and usage of lib/*.c source files done 3-12-2013, reverting 3 commits: 13606bb... build: make use of 93 lib/*.c renamed files 5b6e792... build: rename 93 lib/*.c files 7d83dff... build: commit 13606bbfde follow-up 1 Start of related discussion thread: http://curl.haxx.se/mail/lib-2013-01/0012.html Asking for confirmation on pushing this revertion commit: http://curl.haxx.se/mail/lib-2013-01/0048.html Confirmation summary: http://curl.haxx.se/mail/lib-2013-01/0079.html NOTICE: The list of 2 files that have been modified by other intermixed commits, while renamed, and also by at least one of the 6 commits this one reverts follows below. These 2 files will exhibit a hole in history unless git's '--follow' option is used when viewing logs. lib/curl_imap.h lib/curl_smtp.h