cURL / Mailing Lists / curl-library / Single Mail


[ curl-Bugs-979480 ] two limit-rate bugs

From: <>
Date: Thu, 24 Jun 2004 22:07:47 -0700

Bugs item #979480, was opened at 2004-06-25 01:07
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:

Category: client module
Group: crash
Status: Open
Resolution: None
Priority: 5
Submitted By: Bob (robort)
Assigned to: Daniel Stenberg (bagder)
Summary: two limit-rate bugs

Initial Comment:
The --limit-rate option asserts on MacOS X (10.3, at

poll.c:282: failed assertion `pArray != (struct pollfd
*) NULL'

Although poll() is implemented, it's deprecated and its
emulation doesn't allow a NULL file descriptor array
argument; here's the comment from /usr/include/poll.h :

#warning "poll() functionality for Mac OS X is
implemented via an emulation layer on top of select(), not in the kernel directly. It is recommended that
programs running under OS X 10.3 prefer select() over poll(). Configure scripts should look for
the _POLL_EMUL_H_ define (instead of _POLL_H_ or _SYS_POLL_H_) and avoid implementations where poll
is not implemented in the kernel."

Thus here's a tweak to avoid using poll (perhaps this
should be arranged via config, but it's not clear to me
how to do so on Darwin...):

*** 2245,2247 ****
! #ifdef HAVE_POLL
    /* portable subsecond "sleep" */
--- 2245,2247 ----
! #if defined(HAVE_POLL) && !defined(_POLL_EMUL_H_)
    /* portable subsecond "sleep" */

Fine, but then --limit-rate still doesn't work as
expected, failing to throttle the throughput. This is
because someone had the right idea back in version
1.250 to fix the select() timeout to not attempt to set
more than 1E6-1 usec, but didn't get the maths right!
Reach for pencil & paper...

This fix correctly adjusts the milliseconds for the

*** 2261,2263 ****
    timeout.tv_sec = ms/1000;
! ms -= ms/1000;
    timeout.tv_usec = ms * 1000;
--- 2261,2263 ----
    timeout.tv_sec = ms/1000;
! ms %= 1000;
    timeout.tv_usec = ms * 1000;

These main.c diffs are based on 7.12.1-20040625 .


You can respond by visiting:
Received on 2004-06-25