summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormalc <malc@c046a42c-6fe2-441c-8c8c-71466251a162>2009-02-21 05:48:13 +0000
committermalc <malc@c046a42c-6fe2-441c-8c8c-71466251a162>2009-02-21 05:48:13 +0000
commit30525aff78e9ee2099b24a3dc7534317ee130383 (patch)
treeabfe396843a43ee0f3018b4a1b1d61b3ac5ed9d6 /posix-aio-compat.c
parentError checking (diff)
downloadqemu-kvm-30525aff78e9ee2099b24a3dc7534317ee130383.tar.gz
qemu-kvm-30525aff78e9ee2099b24a3dc7534317ee130383.tar.bz2
qemu-kvm-30525aff78e9ee2099b24a3dc7534317ee130383.zip
Avoid infinite loop around timed condition variable
This can happen due to spurious wakeups git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6631 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'posix-aio-compat.c')
-rw-r--r--posix-aio-compat.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/posix-aio-compat.c b/posix-aio-compat.c
index 154b05118..aa1b6f59c 100644
--- a/posix-aio-compat.c
+++ b/posix-aio-compat.c
@@ -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 @@ static void *aio_thread(void *unused)
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);
}