qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [6631] Avoid infinite loop around timed condition variable


From: malc
Subject: [Qemu-devel] [6631] Avoid infinite loop around timed condition variable
Date: Sat, 21 Feb 2009 05:48:14 +0000

Revision: 6631
          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6631
Author:   malc
Date:     2009-02-21 05:48:13 +0000 (Sat, 21 Feb 2009)

Log Message:
-----------
Avoid infinite loop around timed condition variable

This can happen due to spurious wakeups

Modified Paths:
--------------
    trunk/posix-aio-compat.c

Modified: trunk/posix-aio-compat.c
===================================================================
--- trunk/posix-aio-compat.c    2009-02-21 05:48:11 UTC (rev 6630)
+++ trunk/posix-aio-compat.c    2009-02-21 05:48:13 UTC (rev 6631)
@@ -14,7 +14,7 @@
 #include <pthread.h>
 #include <unistd.h>
 #include <errno.h>
-#include <sys/time.h>
+#include <time.h>
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -86,16 +86,17 @@
         struct qemu_paiocb *aiocb;
         size_t offset;
         int ret = 0;
+        qemu_timeval tv;
+        struct timespec ts;
 
+        qemu_gettimeofday(&tv);
+        ts.tv_sec = tv.tv_sec + 10;
+        ts.tv_nsec = 0;
+
         mutex_lock(&lock);
 
         while (TAILQ_EMPTY(&request_list) &&
                !(ret == ETIMEDOUT)) {
-            struct timespec ts = { 0 };
-            qemu_timeval tv;
-
-            qemu_gettimeofday(&tv);
-            ts.tv_sec = tv.tv_sec + 10;
             ret = cond_timedwait(&cond, &lock, &ts);
         }
 






reply via email to

[Prev in Thread] Current Thread [Next in Thread]