Use signalfd() to work around signal/select race
This patch introduces signalfd() to work around the signal/select race in
checking for AIO completions. For platforms that don't support signalfd(), we
emulate it with threads.
There was a long discussion about this approach. I don't believe there are any
fundamental problems with this approach and I believe eliminating the use of
signals is a good thing.
I've tested Windows and Linux using Windows and Linux guests. I've also checked
for disk IO performance regressions.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5187 c046a42c-6fe2-441c-8c8c-71466251a162
diff --git a/block.c b/block.c
index db8244c..a6fd0b1 100644
--- a/block.c
+++ b/block.c
@@ -1280,17 +1280,15 @@
BlockDriverAIOCB *acb;
async_ret = NOT_DONE;
- qemu_aio_wait_start();
acb = bdrv_aio_read(bs, sector_num, buf, nb_sectors,
bdrv_rw_em_cb, &async_ret);
- if (acb == NULL) {
- qemu_aio_wait_end();
+ if (acb == NULL)
return -1;
- }
+
while (async_ret == NOT_DONE) {
qemu_aio_wait();
}
- qemu_aio_wait_end();
+
return async_ret;
}
@@ -1301,17 +1299,13 @@
BlockDriverAIOCB *acb;
async_ret = NOT_DONE;
- qemu_aio_wait_start();
acb = bdrv_aio_write(bs, sector_num, buf, nb_sectors,
bdrv_rw_em_cb, &async_ret);
- if (acb == NULL) {
- qemu_aio_wait_end();
+ if (acb == NULL)
return -1;
- }
while (async_ret == NOT_DONE) {
qemu_aio_wait();
}
- qemu_aio_wait_end();
return async_ret;
}