Workaround for using synchronous modules in AnyEvent?
Marc Lehmann
schmorp at schmorp.de
Tue Apr 16 15:39:36 CEST 2013
On Tue, Apr 16, 2013 at 10:54:03AM +0200, Zsbán Ambrus <ambrus at math.bme.hu> wrote:
> I've met this when I tried to interface libcurl with libev. The
> libcurl interface satisfies the three points listed above: you can ask
> libcurl to notify you whenever it wants you to change the timer or fd
> watchers. Libcurl, however, does its own timekeeping, and when the
> timer watcher expires and you call libcurl back for that, it will
> often believe that it's a little bit too early for the timeout still
> and tells you to call it back 0 milliseconds later.
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).
That would explain it. Otherwise, I'd say this is simply a bug in libcurl,
as the OS normally gives consistent timestamps, and libev makes sure
the timeout has definitely passed, so if the timestamps are consistent,
libcurl almost certainly has a bug in calculating timeouts.
Maybe reporting it against libcurl might get it fixed (libcurl is not
exactly the most bug free product in the world though). And if it's indeed
the problem with time() on linux, then adding about 4ms should do the
trick on most hardware.
--
The choice of a Deliantra, the free code+content MORPG
-----==- _GNU_ http://www.deliantra.net
----==-- _ generation
---==---(_)__ __ ____ __ Marc Lehmann
--==---/ / _ \/ // /\ \/ / schmorp at schmorp.de
-=====/_/_//_/\_,_/ /_/\_\
More information about the anyevent
mailing list