[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 04/17] tests: adjust test-thread-pool to new aio_
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PATCH v2 04/17] tests: adjust test-thread-pool to new aio_poll() semantics |
Date: |
Wed, 17 Apr 2013 15:07:40 +0200 |
aio_poll(ctx, true) will soon block when fd handlers have been set.
Previously aio_poll() would return early if all .io_flush() returned
false. This means we need to check the equivalent of the .io_flush()
condition *before* calling aio_poll(ctx, true) to avoid deadlock.
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
tests/test-thread-pool.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/tests/test-thread-pool.c b/tests/test-thread-pool.c
index 22915aa..f0b2ef1 100644
--- a/tests/test-thread-pool.c
+++ b/tests/test-thread-pool.c
@@ -40,19 +40,13 @@ static void done_cb(void *opaque, int ret)
active--;
}
-/* Wait until all aio and bh activity has finished */
-static void qemu_aio_wait_all(void)
-{
- while (aio_poll(ctx, true)) {
- /* Do nothing */
- }
-}
-
static void test_submit(void)
{
WorkerTestData data = { .n = 0 };
thread_pool_submit(pool, worker_cb, &data);
- qemu_aio_wait_all();
+ while (data.n == 0) {
+ aio_poll(ctx, true);
+ }
g_assert_cmpint(data.n, ==, 1);
}
@@ -65,7 +59,9 @@ static void test_submit_aio(void)
/* The callbacks are not called until after the first wait. */
active = 1;
g_assert_cmpint(data.ret, ==, -EINPROGRESS);
- qemu_aio_wait_all();
+ while (data.ret == -EINPROGRESS) {
+ aio_poll(ctx, true);
+ }
g_assert_cmpint(active, ==, 0);
g_assert_cmpint(data.n, ==, 1);
g_assert_cmpint(data.ret, ==, 0);
@@ -103,7 +99,9 @@ static void test_submit_co(void)
/* qemu_aio_wait_all will execute the rest of the coroutine. */
- qemu_aio_wait_all();
+ while (data.ret == -EINPROGRESS) {
+ aio_poll(ctx, true);
+ }
/* Back here after the coroutine has finished. */
@@ -187,7 +185,9 @@ static void test_cancel(void)
}
/* Finish execution and execute any remaining callbacks. */
- qemu_aio_wait_all();
+ while (active > 0) {
+ aio_poll(ctx, true);
+ }
g_assert_cmpint(active, ==, 0);
for (i = 0; i < 100; i++) {
if (data[i].n == 3) {
--
1.8.1.4
- [Qemu-devel] [PATCH v2 00/17] aio: drop io_flush(), Stefan Hajnoczi, 2013/04/17
- [Qemu-devel] [PATCH v2 01/17] block: stop relying on io_flush() in bdrv_drain_all(), Stefan Hajnoczi, 2013/04/17
- [Qemu-devel] [PATCH v2 06/17] block/curl: drop curl_aio_flush(), Stefan Hajnoczi, 2013/04/17
- [Qemu-devel] [PATCH v2 09/17] block/linux-aio: drop qemu_laio_completion_cb(), Stefan Hajnoczi, 2013/04/17
- [Qemu-devel] [PATCH v2 10/17] block/nbd: drop nbd_have_request(), Stefan Hajnoczi, 2013/04/17
- [Qemu-devel] [PATCH v2 02/17] dataplane/virtio-blk: check exit conditions before aio_poll(), Stefan Hajnoczi, 2013/04/17
- [Qemu-devel] [PATCH v2 05/17] aio: stop using .io_flush(), Stefan Hajnoczi, 2013/04/17
- [Qemu-devel] [PATCH v2 04/17] tests: adjust test-thread-pool to new aio_poll() semantics,
Stefan Hajnoczi <=
- [Qemu-devel] [PATCH v2 13/17] block/ssh: drop return_true(), Stefan Hajnoczi, 2013/04/17
- [Qemu-devel] [PATCH v2 03/17] tests: adjust test-aio to new aio_poll() semantics, Stefan Hajnoczi, 2013/04/17
- [Qemu-devel] [PATCH v2 08/17] block/iscsi: drop iscsi_process_flush(), Stefan Hajnoczi, 2013/04/17
- [Qemu-devel] [PATCH v2 12/17] block/sheepdog: drop have_co_req() and aio_flush_request(), Stefan Hajnoczi, 2013/04/17
- [Qemu-devel] [PATCH v2 16/17] tests: drop event_active_cb(), Stefan Hajnoczi, 2013/04/17
- [Qemu-devel] [PATCH v2 11/17] block/rbd: drop qemu_rbd_aio_flush_cb(), Stefan Hajnoczi, 2013/04/17
- [Qemu-devel] [PATCH v2 07/17] block/gluster: drop qemu_gluster_aio_flush_cb(), Stefan Hajnoczi, 2013/04/17