util/aio-posix: avoid allocating ready_list in aio_prepare()
PATCH 2/2 util/aio-posix: avoid allocating ready_list in aio_prepare()
Now that poll_ready handlers are handled via aio_pending() and aio_dispatch(), the local ready_list in aio_prepare() serves no
purpose: nodes inserted into it are immediately discarded when the function returns.
Eliminate the unnecessary list operations by passing NULL as the ready_list argument to poll_set_started(). Teach poll_set_started() to handle a NULL ready_list by setting poll_ready=true directly on the node instead of calling aio_add_poll_ready_handler().
Signed-off-by Bin Guo <[email protected]>
--- util/aio-posix.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
util/aio-posix.c +6 -4
@@ -241,7 +241,11 @@ static bool poll_set_started(AioContext *ctx, AioHandlerList *ready_list,/* Poll one last time in case ->io_poll_end() raced with the event */ if (!started && node->io_poll (node->opaque)) { -aio_add_poll_ready_handler (ready_list, node); +if (ready_list) { +aio_add_poll_ready_handler (ready_list, node); + }else { + node->poll_ready = true; + } progress = true; } }
@@ -253,14 +257,12 @@ static bool poll_set_started(AioContext *ctx, AioHandlerList *ready_list,bool aio_prepare (AioContext *ctx) { -AioHandlerList ready_list =QLIST_HEAD_INITIALIZER (ready_list); -/* * Poll mode cannot be used with glib's event loop, disable it. * Any handlers that fire in the last poll are marked poll_ready=true * and will be picked up by aio_pending() / aio_dispatch(). */ -poll_set_started (ctx, &ready_list, false); +poll_set_started (ctx,NULL , false); ctx->fdmon_ops->gsource_prepare (ctx);return false;
Signature · 1 line
2.50.1 (Apple Git-155)