forked from Imagelibrary/rtems
2011-01-08 Alin Rus <alin.codejunkie@gmail.com>
* posix/src/aio_misc.c: Fix rtems_aio_remove_req did not iterate over chain. * posix/src/aio_cancel.c: Add debug information. Add check for bad file descriptor. Add else branch for cancel request on empty IQ chain.
This commit is contained in:
@@ -1,3 +1,11 @@
|
||||
2011-01-08 Alin Rus <alin.codejunkie@gmail.com>
|
||||
|
||||
* posix/src/aio_misc.c: Fix rtems_aio_remove_req did not iterate
|
||||
over chain.
|
||||
* posix/src/aio_cancel.c: Add debug information. Add check for
|
||||
bad file descriptor. Add else branch for cancel request on empty
|
||||
IQ chain.
|
||||
|
||||
2011-01-04 Joel Sherrill <joel.sherrill@oarcorp.com>
|
||||
|
||||
* libcsupport/src/error.c: Scheduler Simulator compilation always
|
||||
|
||||
@@ -43,84 +43,85 @@ int aio_cancel(int fildes, struct aiocb *aiocbp)
|
||||
|
||||
pthread_mutex_lock (&aio_request_queue.mutex);
|
||||
|
||||
if (aiocbp == NULL)
|
||||
{
|
||||
if (fcntl (fildes, F_GETFL) < 0) {
|
||||
pthread_mutex_unlock(&aio_request_queue.mutex);
|
||||
rtems_set_errno_and_return_minus_one (EBADF);
|
||||
if (fcntl (fildes, F_GETFD) < 0) {
|
||||
pthread_mutex_unlock(&aio_request_queue.mutex);
|
||||
rtems_set_errno_and_return_minus_one (EBADF);
|
||||
}
|
||||
|
||||
/* if aiocbp is NULL remove all request for given file descriptor */
|
||||
if (aiocbp == NULL) {
|
||||
AIO_printf ("Cancel all requests\n");
|
||||
|
||||
r_chain = rtems_aio_search_fd (&aio_request_queue.work_req, fildes, 0);
|
||||
if (r_chain == NULL) {
|
||||
AIO_printf ("Request chain not on [WQ]\n");
|
||||
|
||||
if (!rtems_chain_is_empty (&aio_request_queue.idle_req)) {
|
||||
r_chain = rtems_aio_search_fd (&aio_request_queue.idle_req, fildes, 0);
|
||||
if (r_chain == NULL) {
|
||||
pthread_mutex_unlock(&aio_request_queue.mutex);
|
||||
return AIO_ALLDONE;
|
||||
}
|
||||
|
||||
AIO_printf ("Request chain on [IQ]\n");
|
||||
|
||||
rtems_chain_extract (&r_chain->next_fd);
|
||||
rtems_aio_remove_fd (r_chain);
|
||||
pthread_mutex_destroy (&r_chain->mutex);
|
||||
pthread_cond_destroy (&r_chain->mutex);
|
||||
free (r_chain);
|
||||
|
||||
pthread_mutex_unlock (&aio_request_queue.mutex);
|
||||
return AIO_CANCELED;
|
||||
}
|
||||
|
||||
r_chain = rtems_aio_search_fd (&aio_request_queue.work_req,
|
||||
fildes,
|
||||
0);
|
||||
if (r_chain == NULL)
|
||||
{
|
||||
if (!rtems_chain_is_empty (&aio_request_queue.idle_req))
|
||||
{
|
||||
r_chain = rtems_aio_search_fd (&aio_request_queue.idle_req,
|
||||
fildes,
|
||||
0);
|
||||
if (r_chain == NULL) {
|
||||
pthread_mutex_unlock(&aio_request_queue.mutex);
|
||||
return AIO_ALLDONE;
|
||||
}
|
||||
|
||||
rtems_chain_extract (&r_chain->next_fd);
|
||||
rtems_aio_remove_fd (r_chain);
|
||||
pthread_mutex_destroy (&r_chain->mutex);
|
||||
pthread_cond_destroy (&r_chain->mutex);
|
||||
free (r_chain);
|
||||
|
||||
pthread_mutex_unlock (&aio_request_queue.mutex);
|
||||
return AIO_CANCELED;
|
||||
}
|
||||
|
||||
pthread_mutex_unlock (&aio_request_queue.mutex);
|
||||
return AIO_ALLDONE;
|
||||
}
|
||||
|
||||
pthread_mutex_lock (&r_chain->mutex);
|
||||
rtems_chain_extract (&r_chain->next_fd);
|
||||
rtems_aio_remove_fd (r_chain);
|
||||
pthread_mutex_unlock (&r_chain->mutex);
|
||||
pthread_mutex_unlock (&aio_request_queue.mutex);
|
||||
return AIO_CANCELED;
|
||||
return AIO_ALLDONE;
|
||||
}
|
||||
|
||||
AIO_printf ("Request chain on [WQ]\n");
|
||||
|
||||
pthread_mutex_lock (&r_chain->mutex);
|
||||
rtems_chain_extract (&r_chain->next_fd);
|
||||
rtems_aio_remove_fd (r_chain);
|
||||
pthread_mutex_unlock (&r_chain->mutex);
|
||||
pthread_mutex_unlock (&aio_request_queue.mutex);
|
||||
return AIO_CANCELED;
|
||||
} else {
|
||||
AIO_printf ("Cancel request\n");
|
||||
|
||||
if (aiocbp->aio_fildes != fildes) {
|
||||
pthread_mutex_unlock (&aio_request_queue.mutex);
|
||||
rtems_set_errno_and_return_minus_one (EINVAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (aiocbp->aio_fildes != fildes) {
|
||||
pthread_mutex_unlock (&aio_request_queue.mutex);
|
||||
rtems_set_errno_and_return_minus_one (EINVAL);
|
||||
}
|
||||
|
||||
r_chain = rtems_aio_search_fd (&aio_request_queue.work_req,
|
||||
fildes,
|
||||
0);
|
||||
if (r_chain == NULL)
|
||||
if (!rtems_chain_is_empty (&aio_request_queue.idle_req))
|
||||
{
|
||||
r_chain = rtems_aio_search_fd (&aio_request_queue.idle_req,
|
||||
fildes,
|
||||
0);
|
||||
if (r_chain == NULL)
|
||||
{
|
||||
pthread_mutex_unlock (&aio_request_queue.mutex);
|
||||
rtems_set_errno_and_return_minus_one (EINVAL);
|
||||
}
|
||||
r_chain = rtems_aio_search_fd (&aio_request_queue.work_req, fildes, 0);
|
||||
if (r_chain == NULL) {
|
||||
if (!rtems_chain_is_empty (&aio_request_queue.idle_req)) {
|
||||
r_chain = rtems_aio_search_fd (&aio_request_queue.idle_req, fildes, 0);
|
||||
if (r_chain == NULL) {
|
||||
pthread_mutex_unlock (&aio_request_queue.mutex);
|
||||
rtems_set_errno_and_return_minus_one (EINVAL);
|
||||
}
|
||||
|
||||
AIO_printf ("Request on [IQ]\n");
|
||||
|
||||
result = rtems_aio_remove_req (&r_chain->perfd, aiocbp);
|
||||
pthread_mutex_unlock (&aio_request_queue.mutex);
|
||||
return result;
|
||||
} else {
|
||||
pthread_mutex_unlock (&aio_request_queue.mutex);
|
||||
return AIO_ALLDONE;
|
||||
}
|
||||
|
||||
result = rtems_aio_remove_req (&r_chain->perfd, aiocbp);
|
||||
pthread_mutex_unlock (&aio_request_queue.mutex);
|
||||
return result;
|
||||
|
||||
}
|
||||
AIO_printf ("Request on [WQ]\n");
|
||||
|
||||
pthread_mutex_lock (&r_chain->mutex);
|
||||
result = rtems_aio_remove_req (&r_chain->perfd, aiocbp);
|
||||
pthread_mutex_unlock (&r_chain->mutex);
|
||||
pthread_mutex_unlock (&aio_request_queue.mutex);
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return AIO_ALLDONE;
|
||||
}
|
||||
|
||||
@@ -179,7 +179,6 @@ void rtems_aio_remove_fd (rtems_aio_request_chain *r_chain)
|
||||
{
|
||||
rtems_chain_control *chain;
|
||||
rtems_chain_node *node;
|
||||
|
||||
chain = &r_chain->perfd;
|
||||
node = rtems_chain_first (chain);
|
||||
|
||||
@@ -187,6 +186,7 @@ void rtems_aio_remove_fd (rtems_aio_request_chain *r_chain)
|
||||
{
|
||||
rtems_chain_extract (node);
|
||||
rtems_aio_request *req = (rtems_aio_request *) node;
|
||||
node = rtems_chain_next (node);
|
||||
req->aiocbp->error_code = ECANCELED;
|
||||
req->aiocbp->return_value = -1;
|
||||
free (req);
|
||||
@@ -211,6 +211,9 @@ void rtems_aio_remove_fd (rtems_aio_request_chain *r_chain)
|
||||
|
||||
int rtems_aio_remove_req (rtems_chain_control *chain, struct aiocb *aiocbp)
|
||||
{
|
||||
if (rtems_chain_is_empty (chain))
|
||||
return AIO_ALLDONE;
|
||||
|
||||
rtems_chain_node *node = rtems_chain_first (chain);
|
||||
rtems_aio_request *current;
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ aio_read (struct aiocb *aiocbp)
|
||||
mode = fcntl (aiocbp->aio_fildes, F_GETFL);
|
||||
if (!(((mode & O_ACCMODE) == O_RDONLY) || ((mode & O_ACCMODE) == O_RDWR)))
|
||||
rtems_aio_set_errno_return_minus_one (EBADF, aiocbp);
|
||||
|
||||
|
||||
if (aiocbp->aio_reqprio < 0 || aiocbp->aio_reqprio > AIO_PRIO_DELTA_MAX)
|
||||
rtems_aio_set_errno_return_minus_one (EINVAL, aiocbp);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user