aio_cancel need signal caller after the succeed and fix minor issue in the error handler
This commit is contained in:
parent
fb63c0a293
commit
964f0ab304
@ -98,6 +98,7 @@ int aio_cancel(int fildes, FAR struct aiocb *aiocbp)
|
||||
{
|
||||
FAR struct aio_container_s *aioc;
|
||||
FAR struct aio_container_s *next;
|
||||
pid_t pid;
|
||||
int status;
|
||||
int ret;
|
||||
|
||||
@ -140,17 +141,28 @@ int aio_cancel(int fildes, FAR struct aiocb *aiocbp)
|
||||
status = work_cancel(LPWORK, &aioc->aioc_work);
|
||||
if (status >= 0)
|
||||
{
|
||||
/* Remove the container from the list of pending transfers */
|
||||
|
||||
pid = aioc->aioc_pid;
|
||||
(void)aioc_decant(aioc);
|
||||
|
||||
aiocbp->aio_result = -ECANCELED;
|
||||
ret = AIO_CANCELED;
|
||||
|
||||
/* Signal the client */
|
||||
|
||||
(void)aio_signal(pid, aiocbp);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = AIO_NOTCANCELED;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Can't cancel, the operation is running */
|
||||
|
||||
/* Remove the container from the list of pending transfers */
|
||||
|
||||
(void)aioc_decant(aioc);
|
||||
ret = AIO_NOTCANCELED;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -182,20 +194,24 @@ int aio_cancel(int fildes, FAR struct aiocb *aiocbp)
|
||||
*/
|
||||
|
||||
status = work_cancel(LPWORK, &aioc->aioc_work);
|
||||
|
||||
/* Remove the container from the list of pending transfers */
|
||||
|
||||
next = (FAR struct aio_container_s *)aioc->aioc_link.flink;
|
||||
aiocbp = aioc_decant(aioc);
|
||||
DEBUGASSERT(aiocbp);
|
||||
|
||||
if (status >= 0)
|
||||
{
|
||||
/* Remove the container from the list of pending transfers */
|
||||
|
||||
next = (FAR struct aio_container_s *)aioc->aioc_link.flink;
|
||||
pid = aioc->aioc_pid;
|
||||
aiocbp = aioc_decant(aioc);
|
||||
DEBUGASSERT(aiocbp);
|
||||
|
||||
aiocbp->aio_result = -ECANCELED;
|
||||
if (ret != AIO_NOTCANCELED)
|
||||
{
|
||||
ret = AIO_CANCELED;
|
||||
}
|
||||
|
||||
/* Signal the client */
|
||||
|
||||
(void)aio_signal(pid, aiocbp);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -234,6 +234,7 @@ int aio_fsync(int op, FAR struct aiocb *aiocbp)
|
||||
{
|
||||
/* The result and the errno have already been set */
|
||||
|
||||
aioc_decant(aioc);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
|
@ -109,6 +109,7 @@ void aio_initialize(void)
|
||||
/* Initialize counting semaphores */
|
||||
|
||||
(void)nxsem_init(&g_aioc_freesem, 0, CONFIG_FS_NAIOC);
|
||||
(void)nxsem_setprotocol(&g_aioc_freesem, SEM_PRIO_NONE);
|
||||
(void)nxsem_init(&g_aio_exclsem, 0, 1);
|
||||
|
||||
g_aio_holder = INVALID_PROCESS_ID;
|
||||
|
@ -94,6 +94,9 @@ int aio_queue(FAR struct aio_container_s *aioc, worker_t worker)
|
||||
FAR struct aiocb *aiocbp = aioc->aioc_aiocbp;
|
||||
DEBUGASSERT(aiocbp);
|
||||
|
||||
#ifdef CONFIG_PRIORITY_INHERITANCE
|
||||
lpwork_restorepriority(aioc->aioc_prio);
|
||||
#endif
|
||||
aiocbp->aio_result = ret;
|
||||
set_errno(-ret);
|
||||
ret = ERROR;
|
||||
|
@ -283,6 +283,7 @@ int aio_read(FAR struct aiocb *aiocbp)
|
||||
{
|
||||
/* The result and the errno have already been set */
|
||||
|
||||
aioc_decant(aioc);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
|
@ -56,23 +56,6 @@
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: file_fcntl
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef AIO_HAVE_FILEP
|
||||
static inline int file_fcntl(FAR struct file *filep, int cmd, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int ret;
|
||||
|
||||
va_start(ap, cmd);
|
||||
ret = file_vfcntl(filep, cmd, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: aio_write_worker
|
||||
*
|
||||
@ -333,6 +316,7 @@ int aio_write(FAR struct aiocb *aiocbp)
|
||||
{
|
||||
/* The result and the errno have already been set */
|
||||
|
||||
aioc_decant(aioc);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@
|
||||
struct lio_sighand_s
|
||||
{
|
||||
FAR struct aiocb * const *list; /* List of I/O operations */
|
||||
FAR struct sigevent *sig; /* Describes how to signal the caller */
|
||||
FAR struct sigevent sig; /* Describes how to signal the caller */
|
||||
int nent; /* Number or elements in list[] */
|
||||
pid_t pid; /* ID of client */
|
||||
sigset_t oprocmask; /* sigprocmask to restore */
|
||||
@ -245,7 +245,7 @@ static int lio_sigsetup(FAR struct aiocb * const *list, int nent,
|
||||
/* Initialize the allocated structure */
|
||||
|
||||
sighand->list = list;
|
||||
sighand->sig = sig;
|
||||
sighand->sig = *sig;
|
||||
sighand->nent = nent;
|
||||
sighand->pid = getpid();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user