summaryrefslogtreecommitdiff
path: root/thread-pool.c
diff options
context:
space:
mode:
Diffstat (limited to 'thread-pool.c')
-rw-r--r--thread-pool.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/thread-pool.c b/thread-pool.c
index 6fba913529..4157210d16 100644
--- a/thread-pool.c
+++ b/thread-pool.c
@@ -185,6 +185,13 @@ restart:
qemu_bh_schedule(pool->completion_bh);
elem->common.cb(elem->common.opaque, elem->ret);
+
+ /* We can safely cancel the completion_bh here regardless of someone
+ * else having scheduled it meanwhile because we reenter the
+ * completion function anyway (goto restart).
+ */
+ qemu_bh_cancel(pool->completion_bh);
+
qemu_aio_unref(elem);
goto restart;
} else {