mirror of
https://sourceware.org/git/glibc.git
synced 2025-01-03 00:10:10 +00:00
Don't assume __aio_find_req_fd succeeds since the request might already be processed. Don't do the list handling here, call __aio_remove_request.
This commit is contained in:
parent
da8f38c504
commit
950c1194b1
@ -56,16 +56,20 @@ aio_cancel (fildes, aiocbp)
|
|||||||
|
|
||||||
req = __aio_find_req_fd (fildes);
|
req = __aio_find_req_fd (fildes);
|
||||||
|
|
||||||
|
if (req == NULL)
|
||||||
|
{
|
||||||
|
not_found:
|
||||||
|
pthread_mutex_unlock (&__aio_requests_mutex);
|
||||||
|
__set_errno (EINVAL);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
while (req->aiocbp != (aiocb_union *) aiocbp)
|
while (req->aiocbp != (aiocb_union *) aiocbp)
|
||||||
{
|
{
|
||||||
last = req;
|
last = req;
|
||||||
req = req->next_prio;
|
req = req->next_prio;
|
||||||
if (req == NULL)
|
if (req == NULL)
|
||||||
{
|
goto not_found;
|
||||||
pthread_mutex_unlock (&__aio_requests_mutex);
|
|
||||||
__set_errno (EINVAL);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Don't remove the entry if a thread is already working on it. */
|
/* Don't remove the entry if a thread is already working on it. */
|
||||||
@ -74,28 +78,7 @@ aio_cancel (fildes, aiocbp)
|
|||||||
else if (req->running == yes)
|
else if (req->running == yes)
|
||||||
{
|
{
|
||||||
/* We can remove the entry. */
|
/* We can remove the entry. */
|
||||||
if (last != NULL)
|
__aio_remove_request (last, req, 0);
|
||||||
last->next_prio = req->next_prio;
|
|
||||||
else
|
|
||||||
if (req->next_prio == NULL)
|
|
||||||
{
|
|
||||||
if (req->last_fd != NULL)
|
|
||||||
req->last_fd->next_fd = req->next_fd;
|
|
||||||
if (req->next_fd != NULL)
|
|
||||||
req->next_fd->last_fd = req->last_fd;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (req->last_fd != NULL)
|
|
||||||
req->last_fd->next_fd = req->next_prio;
|
|
||||||
if (req->next_fd != NULL)
|
|
||||||
req->next_fd->last_fd = req->next_prio;
|
|
||||||
req->next_prio->last_fd = req->last_fd;
|
|
||||||
req->next_prio->next_fd = req->next_fd;
|
|
||||||
|
|
||||||
/* Mark this entry as runnable. */
|
|
||||||
req->next_prio->running = yes;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = AIO_CANCELED;
|
result = AIO_CANCELED;
|
||||||
}
|
}
|
||||||
@ -122,15 +105,10 @@ aio_cancel (fildes, aiocbp)
|
|||||||
result = AIO_NOTCANCELED;
|
result = AIO_NOTCANCELED;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
result = AIO_CANCELED;
|
||||||
/* Remove entry from the file descriptor list. */
|
|
||||||
if (req->last_fd != NULL)
|
|
||||||
req->last_fd->next_fd = req->next_fd;
|
|
||||||
if (req->next_fd != NULL)
|
|
||||||
req->next_fd->last_fd = req->last_fd;
|
|
||||||
|
|
||||||
result = AIO_CANCELED;
|
/* We can remove the entry. */
|
||||||
}
|
__aio_remove_request (NULL, req, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user