diff --git a/util/aio-posix.c b/util/aio-posix.c index 7f2c99729d4475640b7c6b21977123a8e6f97bae..ed0c79e345889bcbb15db0d39f1c83e77e62e910 100644 --- a/util/aio-posix.c +++ b/util/aio-posix.c @@ -546,7 +546,14 @@ static bool run_poll_handlers(AioContext *ctx, AioHandlerList *ready_list, elapsed_time = qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - start_time; max_ns = qemu_soonest_timeout(*timeout, max_ns); assert(!(max_ns && progress)); - } while (elapsed_time < max_ns && !ctx->fdmon_ops->need_wait(ctx)); + + if (ctx->fdmon_ops->need_wait(ctx)) { + if (fdmon_supports_polling(ctx)) { + *timeout = 0; /* stay in polling mode */ + } + break; + } + } while (elapsed_time < max_ns); if (remove_idle_poll_handlers(ctx, ready_list, start_time + elapsed_time)) { @@ -662,7 +669,7 @@ bool aio_poll(AioContext *ctx, bool blocking) * up IO threads when some work becomes pending. It is essential to * avoid hangs or unnecessary latency. */ - if (poll_set_started(ctx, &ready_list, false)) { + if (timeout && poll_set_started(ctx, &ready_list, false)) { timeout = 0; progress = true; }