aboutsummaryrefslogtreecommitdiff
path: root/src/platform/posix
diff options
context:
space:
mode:
Diffstat (limited to 'src/platform/posix')
-rw-r--r--src/platform/posix/posix_epdesc.c16
-rw-r--r--src/platform/posix/posix_pipedesc.c9
-rw-r--r--src/platform/posix/posix_resolv_gai.c3
3 files changed, 19 insertions, 9 deletions
diff --git a/src/platform/posix/posix_epdesc.c b/src/platform/posix/posix_epdesc.c
index 7a91b4ec..a8c8395e 100644
--- a/src/platform/posix/posix_epdesc.c
+++ b/src/platform/posix/posix_epdesc.c
@@ -46,13 +46,17 @@ struct nni_posix_epdesc {
};
static void
-nni_posix_epdesc_cancel(nni_aio *aio)
+nni_posix_epdesc_cancel(nni_aio *aio, int rv)
{
nni_posix_epdesc *ed = aio->a_prov_data;
+ NNI_ASSERT(rv != 0);
nni_mtx_lock(&ed->mtx);
- nni_aio_list_remove(aio);
- NNI_ASSERT(aio->a_pipe == NULL);
+ if (nni_aio_list_active(aio)) {
+ nni_aio_list_remove(aio);
+ NNI_ASSERT(aio->a_pipe == NULL);
+ nni_aio_finish_error(aio, rv);
+ }
nni_mtx_unlock(&ed->mtx);
}
@@ -70,8 +74,10 @@ nni_posix_epdesc_finish(nni_aio *aio, int rv, int newfd)
(void) close(newfd);
}
}
- if ((nni_aio_finish_pipe(aio, rv, pd) != 0) && (pd != NULL)) {
- nni_posix_pipedesc_fini(pd);
+ if (rv != 0) {
+ nni_aio_finish_error(aio, rv);
+ } else {
+ nni_aio_finish_pipe(aio, pd);
}
}
diff --git a/src/platform/posix/posix_pipedesc.c b/src/platform/posix/posix_pipedesc.c
index 5dd77dcb..bd74e0c0 100644
--- a/src/platform/posix/posix_pipedesc.c
+++ b/src/platform/posix/posix_pipedesc.c
@@ -39,7 +39,7 @@ static void
nni_posix_pipedesc_finish(nni_aio *aio, int rv)
{
nni_aio_list_remove(aio);
- (void) nni_aio_finish(aio, rv, aio->a_count);
+ nni_aio_finish(aio, rv, aio->a_count);
}
static void
@@ -233,12 +233,15 @@ nni_posix_pipedesc_close(nni_posix_pipedesc *pd)
}
static void
-nni_posix_pipedesc_cancel(nni_aio *aio)
+nni_posix_pipedesc_cancel(nni_aio *aio, int rv)
{
nni_posix_pipedesc *pd = aio->a_prov_data;
nni_mtx_lock(&pd->mtx);
- nni_aio_list_remove(aio);
+ if (nni_aio_list_active(aio)) {
+ nni_aio_list_remove(aio);
+ nni_aio_finish_error(aio, rv);
+ }
nni_mtx_unlock(&pd->mtx);
}
diff --git a/src/platform/posix/posix_resolv_gai.c b/src/platform/posix/posix_resolv_gai.c
index 5852f34c..09d40b94 100644
--- a/src/platform/posix/posix_resolv_gai.c
+++ b/src/platform/posix/posix_resolv_gai.c
@@ -62,7 +62,7 @@ nni_posix_resolv_finish(nni_posix_resolv_item *item, int rv)
}
static void
-nni_posix_resolv_cancel(nni_aio *aio)
+nni_posix_resolv_cancel(nni_aio *aio, int rv)
{
nni_posix_resolv_item *item;
@@ -75,6 +75,7 @@ nni_posix_resolv_cancel(nni_aio *aio)
nni_mtx_unlock(&nni_posix_resolv_mtx);
nni_task_cancel(&item->task);
NNI_FREE_STRUCT(item);
+ nni_aio_finish_error(aio, rv);
}
static int