curl-library
RE: GetTickCount vs QueryPerformanceCounter
Date: Thu, 27 May 2010 18:00:39 +0200 (CEST)
On Thu, 27 May 2010, Igor Novoseltsev wrote:
> One note, according to documentation on GetTickCount()
> (http://msdn.microsoft.com/en-us/library/ms724408(VS.85).aspx) it has a 16
> msec resolution, even on the most precious timing hardware. And libcurl
> needs 1 msec resolution.
That's not true.
libcurl doesn't _need_ hardly any precision, what it needs is that your timers
don't fire off before the time has elapsed. Many systems out there provide
timers with less precision than 1ms and they work perfectly fine with libcurl
still.
This said, will a patch similar to this one below fix your problem?
--- a/lib/multi.c
+++ b/lib/multi.c
@@ -1994,9 +1994,11 @@ static CURLMcode multi_socket(struct Curl_multi *multi,
extracts a matching node if there is one */
now = Curl_tvnow();
- now.tv_usec += 1000; /* to compensate for the truncating of 999us to 0ms,
- we always add time here to make the comparison
- below better */
+ now.tv_usec += 40000; /* compensate for bad precision timers */
+ if(now.tv_usec > 1000000) {
+ now.tv_sec++;
+ now.tv_usec -= 1000000;
+ }
multi->timetree = Curl_splaygetbest(now, multi->timetree, &t);
if(t) {
-- / daniel.haxx.se ------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.htmlReceived on 2010-05-27