mirror of
https://github.com/fluencelabs/musl
synced 2025-06-21 02:31:50 +00:00
make aio_suspend a cancellation point and properly handle cancellation
This commit is contained in:
@ -15,6 +15,8 @@ int aio_suspend(const struct aiocb *const cbs[], int cnt, const struct timespec
|
|||||||
int nzcnt = 0;
|
int nzcnt = 0;
|
||||||
const struct aiocb *cb = 0;
|
const struct aiocb *cb = 0;
|
||||||
|
|
||||||
|
pthread_testcancel();
|
||||||
|
|
||||||
if (cnt<0) {
|
if (cnt<0) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
@ -61,10 +63,14 @@ int aio_suspend(const struct aiocb *const cbs[], int cnt, const struct timespec
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = __timedwait(pfut, expect, CLOCK_MONOTONIC, ts?&at:0, 1);
|
ret = __timedwait_cp(pfut, expect, CLOCK_MONOTONIC, ts?&at:0, 1);
|
||||||
|
|
||||||
if (ret) {
|
switch (ret) {
|
||||||
errno = ret==ETIMEDOUT ? EAGAIN : ret;
|
case ETIMEDOUT:
|
||||||
|
ret = EAGAIN;
|
||||||
|
case ECANCELED:
|
||||||
|
case EINTR:
|
||||||
|
errno = ret;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user