cURL / Mailing Lists / curl-library / Single Mail

curl-library

timeout_ms < 1000

From: Jonathan Rom <yoni_at_metacafe.com>
Date: Thu, 13 May 2010 20:28:32 +0000 (UTC)

Hi,

There is a problem setting a timeout of less than one second.
If I set the timeout to less than one second curl returns a timeout instantly.

I have located the culprit in hostip.c where there is a check if timeout < 1000:

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.

My guess is that if there is under 1 second remaining curl wont
even try to resolve the host since alarm has second resolution
(as indicated by the comment) but that is not a correct
assumption since name resolution may take much less than a second.

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-13