From d017a6af12dcf9660f7acc149c0a809a7247aa9c Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Tue, 3 Dec 2024 22:46:48 -0500 Subject: [PATCH] windows ipc: check the return value of nni_aio_schedule This hopefully addresses a long standing bug with Windows IPC sometimes hanging on shut down. --- src/platform/windows/win_ipclisten.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/platform/windows/win_ipclisten.c b/src/platform/windows/win_ipclisten.c index 3d39ed71b..b7b7b5260 100644 --- a/src/platform/windows/win_ipclisten.c +++ b/src/platform/windows/win_ipclisten.c @@ -257,6 +257,7 @@ static void ipc_listener_accept(void *arg, nni_aio *aio) { ipc_listener *l = arg; + int rv; if (nni_aio_begin(aio) != 0) { return; } @@ -266,10 +267,13 @@ ipc_listener_accept(void *arg, nni_aio *aio) nni_aio_finish_error(aio, NNG_ESTATE); return; } - nni_aio_schedule(aio, ipc_accept_cancel, l); - nni_list_append(&l->aios, aio); - if (nni_list_first(&l->aios) == aio) { - ipc_accept_start(l); + if ((rv = nni_aio_schedule(aio, ipc_accept_cancel, l)) != 0) { + nni_aio_finish_error(aio, rv); + } else { + nni_list_append(&l->aios, aio); + if (nni_list_first(&l->aios) == aio) { + ipc_accept_start(l); + } } nni_mtx_unlock(&l->mtx); }