qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [6631] Avoid infinite loop around timed condition variable
@ 2009-02-21  5:48 malc
       [not found] ` <9D64DDB2-3C4E-457D-B1E6-4B56ED65331C@hotmail.com>
  0 siblings, 1 reply; 5+ messages in thread
From: malc @ 2009-02-21  5:48 UTC (permalink / raw)
  To: qemu-devel

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);
         }
 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-02-23 15:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-21  5:48 [Qemu-devel] [6631] Avoid infinite loop around timed condition variable malc
     [not found] ` <9D64DDB2-3C4E-457D-B1E6-4B56ED65331C@hotmail.com>
2009-02-21  5:58   ` C.W. Betts
2009-02-21  6:43     ` malc
2009-02-23 15:16     ` Anthony Liguori
2009-02-23 15:19     ` Anthony Liguori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).