mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 13:27:01 +08:00
Add test for aio_cancel() and fix some bugs found by the test
This commit is contained in:
+22
-7
@@ -160,11 +160,19 @@ int aio_cancel(int fildes, FAR struct aiocb *aiocbp)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
status = work_cancel(LPWORK, &aioc->aioc_work);
|
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 */
|
/* Remove the container from the list of pending transfers */
|
||||||
|
|
||||||
(void)aioc_decant(aioc);
|
(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 */
|
/* Remove the container from the list of pending transfers */
|
||||||
|
|
||||||
next = (FAR struct aio_container_s *)aioc->aioc_link.flink;
|
next = (FAR struct aio_container_s *)aioc->aioc_link.flink;
|
||||||
(void)aioc_decant(aioc);
|
aiocbp = aioc_decant(aioc);
|
||||||
|
DEBUGASSERT(aiocbp);
|
||||||
|
|
||||||
/* Keep track of the return status */
|
if (status >= 0)
|
||||||
|
|
||||||
if (ret != AIO_NOTCANCELED)
|
|
||||||
{
|
{
|
||||||
ret = status >= 0 ? AIO_CANCELED : AIO_NOTCANCELED;
|
aiocbp->aio_result = -ECANCELED;
|
||||||
|
if (ret != AIO_NOTCANCELED)
|
||||||
|
{
|
||||||
|
ret = AIO_CANCELED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = AIO_NOTCANCELED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user