Skip to content

Commit

Permalink
fix deadlock on socket close
Browse files Browse the repository at this point in the history
when an `aio` has no `a_cancel_fn` and the task is in `task_prep` abort it on `nni_aio_stop` call
  • Loading branch information
alzix authored and gdamore committed Apr 24, 2024
1 parent 4ac5db0 commit aac4dc3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/core/aio.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ nni_aio_fini(nni_aio *aio)

if (fn != NULL) {
fn(aio, arg, NNG_ECLOSED);
} else {
nni_task_abort(&aio->a_task);
}

nni_task_fini(&aio->a_task);
Expand Down Expand Up @@ -215,6 +217,8 @@ nni_aio_stop(nni_aio *aio)

if (fn != NULL) {
fn(aio, arg, NNG_ECANCELED);
} else {
nni_task_abort(&aio->a_task);
}

nni_aio_wait(aio);
Expand All @@ -240,6 +244,8 @@ nni_aio_close(nni_aio *aio)

if (fn != NULL) {
fn(aio, arg, NNG_ECLOSED);
} else {
nni_task_abort(&aio->a_task);
}
}
}
Expand Down Expand Up @@ -439,6 +445,8 @@ nni_aio_abort(nni_aio *aio, int rv)
// Stop any I/O at the provider level.
if (fn != NULL) {
fn(aio, arg, rv);
} else {
nni_task_abort(&aio->a_task);
}
}

Expand Down

0 comments on commit aac4dc3

Please sign in to comment.