aboutsummaryrefslogtreecommitdiff
path: root/lib/select.c
AgeCommit message (Collapse)Author
2014-08-11Curl_poll + Curl_wait_ms: fix timeout return valuePeter Wang
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.
2014-05-27select: with winsock, avoid passing unsupported arguments to select()Brad Spencer
"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
2013-03-12curl_global_init: accept the CURL_GLOBAL_ACK_EINTR flagZdenek Pavlas
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
2013-01-09build: fix circular header inclusion with other packagesYang Tse
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.
2013-01-06Revert changes relative to lib/*.[ch] recent renamingYang Tse
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
2013-01-03build: rename 93 lib/*.c filesYang Tse
93 lib/*.c source files renamed to use our standard naming scheme. This commit only does the file renaming. ---------------------------------------- renamed: lib/amigaos.c -> lib/curl_amigaos.c renamed: lib/asyn-ares.c -> lib/curl_asyn_ares.c renamed: lib/asyn-thread.c -> lib/curl_asyn_thread.c renamed: lib/axtls.c -> lib/curl_axtls.c renamed: lib/base64.c -> lib/curl_base64.c renamed: lib/bundles.c -> lib/curl_bundles.c renamed: lib/conncache.c -> lib/curl_conncache.c renamed: lib/connect.c -> lib/curl_connect.c renamed: lib/content_encoding.c -> lib/curl_content_encoding.c renamed: lib/cookie.c -> lib/curl_cookie.c renamed: lib/cyassl.c -> lib/curl_cyassl.c renamed: lib/dict.c -> lib/curl_dict.c renamed: lib/easy.c -> lib/curl_easy.c renamed: lib/escape.c -> lib/curl_escape.c renamed: lib/file.c -> lib/curl_file.c renamed: lib/fileinfo.c -> lib/curl_fileinfo.c renamed: lib/formdata.c -> lib/curl_formdata.c renamed: lib/ftp.c -> lib/curl_ftp.c renamed: lib/ftplistparser.c -> lib/curl_ftplistparser.c renamed: lib/getenv.c -> lib/curl_getenv.c renamed: lib/getinfo.c -> lib/curl_getinfo.c renamed: lib/gopher.c -> lib/curl_gopher.c renamed: lib/gtls.c -> lib/curl_gtls.c renamed: lib/hash.c -> lib/curl_hash.c renamed: lib/hmac.c -> lib/curl_hmac.c renamed: lib/hostasyn.c -> lib/curl_hostasyn.c renamed: lib/hostcheck.c -> lib/curl_hostcheck.c renamed: lib/hostip.c -> lib/curl_hostip.c renamed: lib/hostip4.c -> lib/curl_hostip4.c renamed: lib/hostip6.c -> lib/curl_hostip6.c renamed: lib/hostsyn.c -> lib/curl_hostsyn.c renamed: lib/http.c -> lib/curl_http.c renamed: lib/http_chunks.c -> lib/curl_http_chunks.c renamed: lib/http_digest.c -> lib/curl_http_digest.c renamed: lib/http_negotiate.c -> lib/curl_http_negotiate.c renamed: lib/http_negotiate_sspi.c -> lib/curl_http_negotiate_sspi.c renamed: lib/http_proxy.c -> lib/curl_http_proxy.c renamed: lib/idn_win32.c -> lib/curl_idn_win32.c renamed: lib/if2ip.c -> lib/curl_if2ip.c renamed: lib/imap.c -> lib/curl_imap.c renamed: lib/inet_ntop.c -> lib/curl_inet_ntop.c renamed: lib/inet_pton.c -> lib/curl_inet_pton.c renamed: lib/krb4.c -> lib/curl_krb4.c renamed: lib/krb5.c -> lib/curl_krb5.c renamed: lib/ldap.c -> lib/curl_ldap.c renamed: lib/llist.c -> lib/curl_llist.c renamed: lib/md4.c -> lib/curl_md4.c renamed: lib/md5.c -> lib/curl_md5.c renamed: lib/memdebug.c -> lib/curl_memdebug.c renamed: lib/mprintf.c -> lib/curl_mprintf.c renamed: lib/multi.c -> lib/curl_multi.c renamed: lib/netrc.c -> lib/curl_netrc.c renamed: lib/non-ascii.c -> lib/curl_non_ascii.c renamed: lib/curl_non-ascii.h -> lib/curl_non_ascii.h renamed: lib/nonblock.c -> lib/curl_nonblock.c renamed: lib/nss.c -> lib/curl_nss.c renamed: lib/nwlib.c -> lib/curl_nwlib.c renamed: lib/nwos.c -> lib/curl_nwos.c renamed: lib/openldap.c -> lib/curl_openldap.c renamed: lib/parsedate.c -> lib/curl_parsedate.c renamed: lib/pingpong.c -> lib/curl_pingpong.c renamed: lib/polarssl.c -> lib/curl_polarssl.c renamed: lib/pop3.c -> lib/curl_pop3.c renamed: lib/progress.c -> lib/curl_progress.c renamed: lib/qssl.c -> lib/curl_qssl.c renamed: lib/rawstr.c -> lib/curl_rawstr.c renamed: lib/rtsp.c -> lib/curl_rtsp.c renamed: lib/security.c -> lib/curl_security.c renamed: lib/select.c -> lib/curl_select.c renamed: lib/sendf.c -> lib/curl_sendf.c renamed: lib/share.c -> lib/curl_share.c renamed: lib/slist.c -> lib/curl_slist.c renamed: lib/smtp.c -> lib/curl_smtp.c renamed: lib/socks.c -> lib/curl_socks.c renamed: lib/socks_gssapi.c -> lib/curl_socks_gssapi.c renamed: lib/socks_sspi.c -> lib/curl_socks_sspi.c renamed: lib/speedcheck.c -> lib/curl_speedcheck.c renamed: lib/splay.c -> lib/curl_splay.c renamed: lib/ssh.c -> lib/curl_ssh.c renamed: lib/sslgen.c -> lib/curl_sslgen.c renamed: lib/ssluse.c -> lib/curl_ssluse.c renamed: lib/strdup.c -> lib/curl_strdup.c renamed: lib/strequal.c -> lib/curl_strequal.c renamed: lib/strerror.c -> lib/curl_strerror.c renamed: lib/strtok.c -> lib/curl_strtok.c renamed: lib/strtoofft.c -> lib/curl_strtoofft.c renamed: lib/telnet.c -> lib/curl_telnet.c renamed: lib/tftp.c -> lib/curl_tftp.c renamed: lib/timeval.c -> lib/curl_timeval.c renamed: lib/transfer.c -> lib/curl_transfer.c renamed: lib/url.c -> lib/curl_url.c renamed: lib/version.c -> lib/curl_version.c renamed: lib/warnless.c -> lib/curl_warnless.c renamed: lib/wildcard.c -> lib/curl_wildcard.c ----------------------------------------
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-08-07Curl_socket_check: fix timeout return value for select usersDaniel Stenberg
This is the same fix applied for the conditional code that uses select() that was already done for the poll specific code in commit b61e8b81f5038.
2012-08-07Curl_socket_check: fix return code for timeoutMaxime Larocque
We found a problem with ftp transfer using libcurl (7.23 and 7.25) inside an application which is receiving unix signals (SIGUSR1, SIGUSR2...) almost continuously. (Linux 2.4, PowerPC, HAVE_POLL_FINE defined). Curl_socket_check() uses poll() to wait for the socket, and retries it when a signal is received (EINTR). However, if a signal is received and it also happens that the timeout has been reached, Curl_socket_check() returns -1 instead of 0 (indicating an error instead of a timeout). In our case, the result is an aborted connection even before the ftp banner is received from the server, and a return value of CURLE_OUT_OF_MEMORY from curl_easy_perform() (Curl_pp_multi_statemach(), in pingpong.c, actually returns OOM if Curl_socket_check() fails :-) Funny to debug on a system on which OOM is a possible cause). Bug: http://curl.haxx.se/mail/lib-2012-07/0122.html
2011-12-20Curl_socket_check: enlarge poll struct array to 3Daniel Stenberg
This function was introduced in commit 5527417afae0 and as pointed out by Gokhan Sengun, the array with poll structs must large enough to hold 3 sockets since that is what the function can accept. It could be noted that he had this fixed in his patch as posted in http://curl.haxx.se/mail/lib-2011-12/0179.html Bug: http://curl.haxx.se/mail/lib-2011-12/0228.html Reported by: Gokhan Sengun
2011-12-20sockets: new Curl_socket_check() can wait for 3 socketsDaniel Stenberg
This offers an alternative to the existing Curl_socket_ready() API which only checks one socket for read and one for write.
2011-09-25curl_multi_fdset: avoid FD_SET out of boundsDaniel Stenberg
If a socket is larger than FD_SETSIZE, avoid using FD_SET() on the platforms where this is possible. Bug: http://curl.haxx.se/bug/view.cgi?id=3413274 Reported by: Tim Starling
2011-09-03fix a bunch of MSVC compiler warningsYang Tse
2011-09-02MemoryTracking: fix logging of free() calls done where Curl_safefree is calledYang Tse
Just internal stuff... Curl_safefree is now a macro defined in memdebug.h instead of a function prototyped in url.h and implemented in url.c, so inclusion of url.h is no longer required in order to simply use Curl_safefree. Provide definition of macro WHILE_FALSE in setup_once.h in order to allow other macros such as DEBUGF and DEBUGASSERT, and code using it, to compile without 'conditional expression is constant' warnings. The WHILE_FALSE stuff fixes 150+ MSVC compiler warnings.
2011-07-28Give the NTLM SSO helper a moment to cleanly shut down if neededDan Fandrich
2011-07-25time.h and sys/time.h inclusion conditionally done in setup_once.hYang Tse
2011-06-11long/int messDaniel Stenberg
Typecast when converting to int from long to avoid some compiler warnings
2011-06-05wait_ms: takes an int argumentDaniel Stenberg
Typecasts added since I changed more code to use long for timeouts
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-24compiler warning: fixYang Tse
Fix compiler warning: variable was set but never used Fix compiler warning: clobber ignored
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.
2010-03-24remove the CVSish $Id$ linesDaniel Stenberg
2009-10-27Fix spellingYang Tse
2009-09-15Some systems poll function sets POLLHUP in revents without settingYang Tse
POLLIN, and sets POLLERR without setting POLLIN and POLLOUT. In some libcurl code execution paths this could trigger busy wait loops with high CPU usage until a timeout condition aborted the loop. This fix for Curl_poll adresses the above in a libcurl-wide mode.
2008-05-26Andreas Faerber and Scott McCreary made (lib)curl build for the Haiku OSDaniel Stenberg
2008-05-09Internal time differences now use monotonic time source if available.Yang Tse
This also implies the removal of the winmm.lib dependency for WIN32.
2008-03-06Regression fix:Yang Tse
select/poll calls will only be retried upon EINTR failures as it previously was in lib/select.c revision 1.29 In this way Curl_socket_ready() and Curl_poll() will again fail on any select/poll errors different than EINTR.
2007-11-05removed space after if and while before the parenthesis for better source codeDaniel Stenberg
consistency
2007-10-03Cleanup no longer used macrosYang Tse
2007-10-03Fix compiler warning: local variable may be used without having been initializedYang Tse
2007-05-31When transferring 500 downloads in parallel with a c-ares enabled build onlyDaniel Stenberg
to find that it crashed miserably, and this was due to some select()isms left in the code. This was due to API restrictions in c-ares 1.3.x, but with the upcoming c-ares 1.4.0 this is no longer the case so now libcurl runs much better with c-ares and the multi interface with > 1024 file descriptors in use.
2007-05-26Primarily this fixes an off-by-one buffer overwrite (rare but still existing).Daniel Stenberg
I also switched from calloc() to malloc() as a minor performance boost since the rest of the code fills in the structs fine anyway - and they must for the case when we use the stack-based auto variable array instead of the allocated one. I made the loop filling in poll_fds[] break when poll_nfds is reached as a minor speed improvement.
2007-04-20initialize pending_ms to zero to avoid compiler warning:Yang Tse
'pending_ms' may be used uninitialized in this function
2007-04-20- Save one call to curlx_tvnow(), which calls gettimeofday(), in each ofYang Tse
Curl_socket_ready(), Curl_poll() and Curl_select() when these are called with a zero timeout or a timeout value indicating a blocking call should be performed. These unnecessary calls to gettimeofday() got introduced in 7.16.2 when fixing 'timeout would restart when signal caught while awaiting socket events' on 20 March 2007. - Move some loop breaking logic from the while clause into the loop, avoiding compiler warning 'assignment within conditional expression'
2007-04-19keep lines < 80 columnsDaniel Stenberg
2007-04-16- Robert Iakobashvil added curl_multi_socket_action() to libcurl, which is aDaniel Stenberg
function that deprecates the curl_multi_socket() function. Using the new function the application tell libcurl what action that was found in the socket that it passes in. This gives a significant performance boost as it allows libcurl to avoid a call to poll()/select() for every call to curl_multi_socket*().
2007-04-04move WinSock definitions of EBADF, EINTR, EINVAL and EAFNOSUPPORT to ↵Yang Tse
setup_once.h
2007-04-03fix MSDOS symbol checkYang Tse
2007-04-02fix compiler warningYang Tse
2007-03-29fix error introduced in last commitYang Tse
2007-03-28Improve detection of socket events which allow a further recv() callYang Tse
to complete with no delay and actually find out what happened with the socket. As well as detection of socket send()able condition. This also allows removal of a Cygwin specific block of code.
2007-03-27New Internal wrapper function Curl_select() around select (2), itYang Tse
uses poll() when a fine poll() is available, so now libcurl can be built without select() support at all if a fine poll() is available.
2007-03-27don't retry select() call upon unrecoverable error EBADFYang Tse
2007-03-26Internal function Curl_select() renamed to Curl_socket_ready()Yang Tse
2007-03-22Add a couple of local macros to improve code readability.Yang Tse
For completeness sake, wait_ms() might also get interrupted when experimental CURL_ACKNOWLEDGE_EINTR is defined.
2007-03-21fix compiler warning: implicit conversion from "long" to "int"Yang Tse
2007-03-20Fixed: When a signal was caught awaiting for an event using Curl_select()Yang Tse
or Curl_poll() with a non-zero timeout both functions would restart the specified timeout. This could even lead to the extreme case that if a signal arrived with a frecuency lower to the specified timeout neither function would ever exit. Added experimental symbol definition check CURL_ACKNOWLEDGE_EINTR in Curl_select() and Curl_poll(). When compiled with CURL_ACKNOWLEDGE_EINTR defined both functions will return as soon as a signal is caught. Use it at your own risk, all calls to these functions in the library should be revisited and checked before fully supporting this feature.
2007-03-18Fix compiler warning/error: ISO C90 forbids mixed declarations and codeYang Tse
2007-03-18Code refactoring, extracting a new function wait_ms() from Curl_select andYang Tse
Curl_poll() which is called whenever not a single valid file descriptor is passed to these functions. Improve readibility using a poll() macro to replace WSApoll().
2007-03-11reverted the pselect patch => http://curl.haxx.se/mail/lib-2007-03/0100.htmlDaniel Stenberg