Skip to content

Commit

Permalink
aio: run callback from aio_begin if stopped
Browse files Browse the repository at this point in the history
There is a very subtle case where an aio can be closed, but we
don't realize it until precisely the moment of nni_aio_begin.
This is eaten, and the submitter winds up having no way of knowing
that the aio is closed, leading to a potential hang, or a leaked
resource.

It is very important that aio users check the return value and do
not resubmit an operation once NNG_ECLOSED is returned.  Otherwise
a circular loop can result.
  • Loading branch information
gdamore committed Dec 9, 2024
1 parent 254b243 commit b4b438c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/aio.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ nni_aio_begin(nni_aio *aio)
aio->a_sleep = false;
aio->a_expire_ok = false;
nni_mtx_unlock(&eq->eq_mtx);

nni_task_dispatch(&aio->a_task);
return (NNG_ECANCELED);
}
nni_task_prep(&aio->a_task);
Expand Down

0 comments on commit b4b438c

Please sign in to comment.