From 67030f90493bbad0cda9836925e4ea97d3e41fa0 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 6 Oct 2014 15:06:01 -0600 Subject: [PATCH] Add test for aio_cancel() and fix some bugs found by the test --- fs/aio/aio_cancel.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/fs/aio/aio_cancel.c b/fs/aio/aio_cancel.c index 11bf950f78e..21efe913e47 100644 --- a/fs/aio/aio_cancel.c +++ b/fs/aio/aio_cancel.c @@ -160,11 +160,19 @@ int aio_cancel(int fildes, FAR struct aiocb *aiocbp) */ status = work_cancel(LPWORK, &aioc->aioc_work); + if (status >= 0) + { + aiocbp->aio_result = -ECANCELED; + ret = AIO_CANCELED; + } + else + { + ret = AIO_NOTCANCELED; + } /* Remove the container from the list of pending transfers */ (void)aioc_decant(aioc); - ret = status >= 0 ? AIO_CANCELED : AIO_NOTCANCELED; } } } @@ -201,14 +209,21 @@ int aio_cancel(int fildes, FAR struct aiocb *aiocbp) /* Remove the container from the list of pending transfers */ - next = (FAR struct aio_container_s *)aioc->aioc_link.flink; - (void)aioc_decant(aioc); + next = (FAR struct aio_container_s *)aioc->aioc_link.flink; + aiocbp = aioc_decant(aioc); + DEBUGASSERT(aiocbp); - /* Keep track of the return status */ - - if (ret != AIO_NOTCANCELED) + if (status >= 0) { - ret = status >= 0 ? AIO_CANCELED : AIO_NOTCANCELED; + aiocbp->aio_result = -ECANCELED; + if (ret != AIO_NOTCANCELED) + { + ret = AIO_CANCELED; + } + } + else + { + ret = AIO_NOTCANCELED; } } }