Commit Graph

67 Commits

Author SHA1 Message Date
Daniel Stenberg 926916e28e Curl_socket_check: enlarge poll struct array to 3
This function was introduced in commit 5527417afa 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-20 23:33:54 +01:00
Daniel Stenberg 5527417afa sockets: new Curl_socket_check() can wait for 3 sockets
This offers an alternative to the existing Curl_socket_ready() API which
only checks one socket for read and one for write.
2011-12-20 20:30:02 +01:00
Daniel Stenberg 2d6796aac5 curl_multi_fdset: avoid FD_SET out of bounds
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-25 17:34:12 +02:00
Yang Tse 6b75d2c2df fix a bunch of MSVC compiler warnings 2011-09-03 16:07:09 +02:00
Yang Tse 9194e17003 MemoryTracking: fix logging of free() calls done where Curl_safefree is called
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-09-02 19:40:53 +02:00
Dan Fandrich 9779553221 Give the NTLM SSO helper a moment to cleanly shut down if needed 2011-07-28 12:42:39 -07:00
Yang Tse 0337b87197 time.h and sys/time.h inclusion conditionally done in setup_once.h 2011-07-25 04:08:08 +02:00
Daniel Stenberg ee015947d4 long/int mess
Typecast when converting to int from long to avoid some compiler warnings
2011-06-11 22:56:45 +02:00
Daniel Stenberg 7559b77727 wait_ms: takes an int argument
Typecasts added since I changed more code to use long for timeouts
2011-06-05 12:06:50 +02:00
Daniel Stenberg 4f170ee8f9 Curl_socket_ready: make timeout a 'long'
It was mostly typecasted to int all over the code so switching to long
instead all over should be a net gain.
2011-06-04 21:19:14 +02:00
Yang Tse b735717606 compiler warning: fix
Fix compiler warning: variable was set but never used

Fix compiler warning: clobber ignored
2011-05-24 20:39:58 +02:00
Daniel Stenberg b903186fa0 source cleanup: unify look, style and indent levels
By the use of a the new lib/checksrc.pl script that checks that our
basic source style rules are followed.
2011-04-27 09:09:35 +02:00
Daniel Stenberg 2309b4e330 remove the CVSish $Id$ lines 2010-03-24 11:02:54 +01:00
Yang Tse 21af9bf1cd Fix spelling 2009-10-27 16:56:20 +00:00
Yang Tse f7690db37d Some systems poll function sets POLLHUP in revents without setting
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.
2009-09-15 00:07:56 +00:00
Daniel Stenberg b97606f0b0 Andreas Faerber and Scott McCreary made (lib)curl build for the Haiku OS 2008-05-26 15:09:28 +00:00
Yang Tse 19479ea021 Internal time differences now use monotonic time source if available.
This also implies the removal of the winmm.lib dependency for WIN32.
2008-05-09 16:31:51 +00:00
Yang Tse 91aeebed26 Regression fix:
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.
2008-03-06 03:48:33 +00:00
Daniel Stenberg ad6e28073c removed space after if and while before the parenthesis for better source code
consistency
2007-11-05 09:45:09 +00:00
Yang Tse a11c8a6ea0 Cleanup no longer used macros 2007-10-03 16:58:10 +00:00
Yang Tse 2858935187 Fix compiler warning: local variable may be used without having been initialized 2007-10-03 16:26:56 +00:00
Daniel Stenberg 4c663ba9a8 When transferring 500 downloads in parallel with a c-ares enabled build only
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-31 11:34:32 +00:00
Daniel Stenberg 8bd7197a8f Primarily this fixes an off-by-one buffer overwrite (rare but still existing).
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-05-26 22:02:29 +00:00
Yang Tse 7f33aae067 initialize pending_ms to zero to avoid compiler warning:
'pending_ms' may be used uninitialized in this function
2007-04-20 01:58:15 +00:00
Yang Tse 61022f3817 - Save one call to curlx_tvnow(), which calls gettimeofday(), in each of
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-20 00:07:19 +00:00
Daniel Stenberg bf648fcfc3 keep lines < 80 columns 2007-04-19 20:20:48 +00:00
Daniel Stenberg 76627b322e - Robert Iakobashvil added curl_multi_socket_action() to libcurl, which is a
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-16 16:34:08 +00:00
Yang Tse 8fe9376d54 move WinSock definitions of EBADF, EINTR, EINVAL and EAFNOSUPPORT to setup_once.h 2007-04-04 06:06:36 +00:00
Yang Tse f1b4f5e2ae fix MSDOS symbol check 2007-04-03 15:35:19 +00:00
Yang Tse 8a7d58378b fix compiler warning 2007-04-02 02:13:26 +00:00
Yang Tse 3d5a8515a6 fix error introduced in last commit 2007-03-29 00:11:55 +00:00
Yang Tse 869d192ffc Improve detection of socket events which allow a further recv() call
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-28 18:59:42 +00:00
Yang Tse eed47311f8 New Internal wrapper function Curl_select() around select (2), it
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-27 18:15:26 +00:00
Yang Tse 59eaae42b8 don't retry select() call upon unrecoverable error EBADF 2007-03-27 15:22:49 +00:00
Yang Tse fba4cd0e62 Internal function Curl_select() renamed to Curl_socket_ready() 2007-03-26 23:23:46 +00:00
Yang Tse 4fb483012c Add a couple of local macros to improve code readability.
For completeness sake, wait_ms() might also get interrupted when
experimental CURL_ACKNOWLEDGE_EINTR is defined.
2007-03-22 15:32:28 +00:00
Yang Tse 842be6c52f fix compiler warning: implicit conversion from "long" to "int" 2007-03-21 07:29:03 +00:00
Yang Tse e4b754f64e Fixed: When a signal was caught awaiting for an event using Curl_select()
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-20 20:00:40 +00:00
Yang Tse da2b75a026 Fix compiler warning/error: ISO C90 forbids mixed declarations and code 2007-03-18 17:29:24 +00:00
Yang Tse 0e2d3b7b6c Code refactoring, extracting a new function wait_ms() from Curl_select and
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-18 04:51:40 +00:00
Daniel Stenberg c8cd13337e reverted the pselect patch => http://curl.haxx.se/mail/lib-2007-03/0100.html 2007-03-11 09:11:29 +00:00
Daniel Stenberg dbaf4f9361 - Bryan Henderson introduces two things:
1) the progress callback gets called more frequently (at times)
  2) libcurl *might* call the callback when it receives a signal
2007-03-10 12:11:21 +00:00
Gisle Vanem c514a2a89a Removed inclusion of <sys/types.h> and <sys/stat.h> in .c-files
since they're already included through "setup.h".
2007-02-26 04:24:26 +00:00
Yang Tse a1d5983991 use macros ERRNO, SET_ERRNO(), SOCKERRNO and SET_SOCKERRNO() for errno handling 2007-02-16 18:19:35 +00:00
Gisle Vanem b7aaa4d907 Include <dos.h> for delay() on MSDOS. 2007-01-05 15:56:28 +00:00
Daniel Stenberg 0682d25da5 - Victor Snezhko helped us fix bug report #1603712
(http://curl.haxx.se/bug/view.cgi?id=1603712) (known bug #36) --limit-rate
  (CURLOPT_MAX_SEND_SPEED_LARGE and CURLOPT_MAX_RECV_SPEED_LARGE) are broken
  on Windows (since 7.16.0, but that's when they were introduced as previous
  to that the limiting logic was made in the application only and not in the
  library). It was actually also broken on select()-based systems (as apposed
  to poll()) but we haven't had any such reports. We now use select(), Sleep()
  or delay() properly to sleep a while without waiting for anything input or
  output when the rate limiting is activated with the easy interface.
2007-01-02 22:34:56 +00:00
Daniel Stenberg 3ce43764be Matt Witherspoon fixed a problem case when the CPU load went to 100% when a
HTTP upload was disconnected:

"What appears to be happening is that my system (Linux 2.6.17 and 2.6.13) is
setting *only* POLLHUP on poll() when the conditions in my previous mail
occur. As you can see, select.c:Curl_select() does not check for POLLHUP. So
basically what was happening, is poll() was returning immediately (with
POLLHUP set), but when Curl_select() looked at the bits, neither POLLERR or
POLLOUT was set. This still caused Curl_readwrite() to be called, which
quickly returned. Then the transfer() loop kept continuing at full speed
forever."
2006-12-05 13:37:05 +00:00
Yang Tse 5df4be1165 Check for USE_WINSOCK instead of WIN32 where the check was done
to verify winsock API availability.
2006-10-18 21:05:40 +00:00
Yang Tse eceb37bde2 Cygwin 1.5.21 needs this hack to pass test 160.
In this way 304 tests out of 304 reported OK.
2006-10-09 00:35:36 +00:00
Daniel Stenberg 1fa3a5cce9 Cory Nelson made libcurl use the WSAPoll() function if built for Windows
Vista (_WIN32_WINNT >= 0x0600)
2006-09-24 10:41:00 +00:00