curl-library
Re: Fix for millisecond precision timeout in libcurl
Date: Wed, 12 May 2010 12:15:00 +0000 (UTC)
Daniel Stenberg <daniel <at> haxx.se> writes:
>
> On Mon, 1 Mar 2010, Moshenko, Jacob wrote:
>
> > When using libcurl I stumbled upon a bug using sub-second precision timeouts
> > with libcurl. If you set millisecond timeouts (e.g. TIMEOUT_MS to 200ms)
> > the logging output will report that it has timed out after the appropriate
> > amount of time. The actual elapsed time however will be rounded up to the
> > nearest second (e.g. 1s for 200ms timeout). I have created a patch to the
> > library that will fix the reporting of the actual timeout duration as well
> > as the timeout itself.
>
> Thank you! Your patch had a faulty assumption that there always was a timeout,
> but I fixed that minor flaw and committed this improvement just now. Please
> checkout the current code and see that it truly works as intended for you!
>
Hi,
I noticed the following patch still does not work with TIMEOUT_MS < 1000 and
this is because the check in hostip.c which states that alarm has only second
resolution.
lib/hostip.c:571
if(timeout < 1000)
/* The alarm() function only provides integer second resolution, so if
we want to wait less than one second we must bail out already now. */
return CURLRESOLV_TIMEDOUT;
if I undef USE_ALARM_TIMEOUT or remove the check it works as expected.
Is there a better solution for this?
Thanks,
Jonathan Rom
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-05-12