summaryrefslogtreecommitdiff
path: root/nuttx
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-10-06 15:06:01 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-10-06 15:06:01 -0600
commitf4555180b5847b4ee4b93c8d06f6741980a26128 (patch)
tree806ae4b955570f4da08809b0598a71e9f770b4e2 /nuttx
parentd934f6b74cb95d96ee4065f75c0110ab0bb12e92 (diff)
downloadpx4-nuttx-f4555180b5847b4ee4b93c8d06f6741980a26128.tar.gz
px4-nuttx-f4555180b5847b4ee4b93c8d06f6741980a26128.tar.bz2
px4-nuttx-f4555180b5847b4ee4b93c8d06f6741980a26128.zip
Add test for aio_cancel() and fix some bugs found by the test
Diffstat (limited to 'nuttx')
-rw-r--r--nuttx/fs/aio/aio_cancel.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/nuttx/fs/aio/aio_cancel.c b/nuttx/fs/aio/aio_cancel.c
index 11bf950f7..21efe913e 100644
--- a/nuttx/fs/aio/aio_cancel.c
+++ b/nuttx/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);
-
- /* Keep track of the return status */
+ next = (FAR struct aio_container_s *)aioc->aioc_link.flink;
+ aiocbp = aioc_decant(aioc);
+ DEBUGASSERT(aiocbp);
- if (ret != AIO_NOTCANCELED)
+ if (status >= 0)
+ {
+ aiocbp->aio_result = -ECANCELED;
+ if (ret != AIO_NOTCANCELED)
+ {
+ ret = AIO_CANCELED;
+ }
+ }
+ else
{
- ret = status >= 0 ? AIO_CANCELED : AIO_NOTCANCELED;
+ ret = AIO_NOTCANCELED;
}
}
}