aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Zilberkant <azilberk@akamai.com>2024-04-24 21:53:35 +0300
committerGarrett D'Amore <garrett@damore.org>2024-04-24 14:11:02 -0700
commitaac4dc360faca9ccece487ba16371d20d90e6406 (patch)
treeffed99768039cc5a12a9da329ddc2819e6318a7a
parent4ac5db0d97e4ca2d6f97a687e9615951215fd7ce (diff)
downloadnng-aac4dc360faca9ccece487ba16371d20d90e6406.tar.gz
nng-aac4dc360faca9ccece487ba16371d20d90e6406.tar.bz2
nng-aac4dc360faca9ccece487ba16371d20d90e6406.zip
fix deadlock on socket close
when an `aio` has no `a_cancel_fn` and the task is in `task_prep` abort it on `nni_aio_stop` call
-rw-r--r--src/core/aio.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/core/aio.c b/src/core/aio.c
index 084795bd..9a21d224 100644
--- a/src/core/aio.c
+++ b/src/core/aio.c
@@ -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);
@@ -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);
@@ -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);
}
}
}
@@ -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);
}
}