]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
virCondWaitUntil: calculate timespec correctly
authorMichael Chapman <mike@very.puzzling.org>
Thu, 16 Apr 2015 09:27:36 +0000 (19:27 +1000)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 16 Apr 2015 13:39:22 +0000 (15:39 +0200)
ts.tv_nsec was off by a factor of 1000, making timeouts less than a
second in the future often expiring immediately.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
src/util/virthread.c

index c2a9e7faaae95727d0baf4a42d72971cf1d508cf..6c495158f5665804585715abba3c414a87dc329f 100644 (file)
@@ -164,7 +164,7 @@ int virCondWaitUntil(virCondPtr c, virMutexPtr m, unsigned long long whenms)
     struct timespec ts;
 
     ts.tv_sec = whenms / 1000;
-    ts.tv_nsec = (whenms % 1000) * 1000;
+    ts.tv_nsec = (whenms % 1000) * 1000000;
 
     if ((ret = pthread_cond_timedwait(&c->cond, &m->lock, &ts)) != 0) {
         errno = ret;