[libvirt] [PATCH] virCondWaitUntil: calculate timespec correctly

Martin Kletzander mkletzan at redhat.com
Thu Apr 16 13:51:13 UTC 2015


On Thu, Apr 16, 2015 at 03:48:25PM +0200, Martin Kletzander wrote:
>On Thu, Apr 16, 2015 at 07:27:36PM +1000, Michael Chapman wrote:
>>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 at very.puzzling.org>
>>---
>>src/util/virthread.c | 2 +-
>>1 file changed, 1 insertion(+), 1 deletion(-)
>>
>
>Wow, we had a bug like that there since...  The introduction of that
>function in commit e40438fa.  That's more than 5 years.
>
>Good catch, ACK, I'll push this shortly.
>

Or not, Michal pushed it already, my mail is slowed down. :)

>>diff --git a/src/util/virthread.c b/src/util/virthread.c
>>index c2a9e7f..6c49515 100644
>>--- a/src/util/virthread.c
>>+++ b/src/util/virthread.c
>>@@ -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;
>>--
>>2.1.0
>>
>>--
>>libvir-list mailing list
>>libvir-list at redhat.com
>>https://www.redhat.com/mailman/listinfo/libvir-list



>--
>libvir-list mailing list
>libvir-list at redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150416/a0177c4d/attachment-0001.sig>


More information about the libvir-list mailing list