libcurl timer callback (Was: Workaround for using synchronous modules in AnyEvent?)
Zsbán Ambrus
ambrus at math.bme.hu
Tue Apr 16 19:52:12 CEST 2013
On 4/16/13, Marc Lehmann <schmorp at schmorp.de> wrote:
> Indeed, but that's really strange. Does libcurl maybe use time(2) für
> timeouts instead of e.g. gettimeofday? On linux, time(2) often lags a
> second behind gettimeofday for several milliseconds after a new second
> starts (a bug, surely, but widespread and probably not going to be fixed).
I don't think time could be the problem. The libcurl interface asks
for the timeout with a time relative to now, as an integer number of
milliseconds. My guess is that the problem was caused by incorrect
roundnig: libcurl would query the time to microsecond precision, then
when it computed it wanted to wait for half a millisecond, it rounded
that down and asked me to wait for 0 milliseconds.
This was, however, four years ago. Libcurl might have been fixed in
the meanwhile. I can't reproduce the problem now, though that could
be because I'm doing something wrong now. The changelog for libcurl
has an entry saying "Fixed in 7.21.0 - June 16 2010:
curl_multi_socket_action() timeout handles inaccuracy in timers
better" which might be the bugfix for this.
Ambrus
More information about the anyevent
mailing list