From: Bian N. <bi...@cn...> - 2011-03-25 02:36:54
|
The aio_suspend may be interrupted by completing signal, so it's better to determine the completion by the associated error using aio_error. POSIX IEEE Std 1003.1-2008 said as following. The aio_suspend() function shall fail if: [EAGAIN] No asynchronous I/O indicated in the list referenced by list completed in the time interval indicated by timeout. [EINTR] A signal interrupted the aio_suspend() function. Note that, since each c I/O operation may possibly provoke a signal when it completes, this error return may be caused by the completion of one (or more) of the very I/O operations being awaited. Signed-off-by: Bian Naimeng <bi...@cn...> --- .../conformance/interfaces/aio_suspend/7-1.c | 35 ++++--------------- 1 files changed, 8 insertions(+), 27 deletions(-) diff --git a/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/7-1.c b/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/7-1.c index 1ba5573..eaae63b 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/7-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/7-1.c @@ -41,19 +41,11 @@ #define BUF_SIZE 1024*1024 #define WAIT_FOR_AIOCB 6 -int received_selected = 0; int received_all = 0; void sigrt1_handler(int signum, siginfo_t *info, void *context) { - if (info->si_value.sival_int == WAIT_FOR_AIOCB) - received_selected = 1; -} - -void -sigrt2_handler(int signum, siginfo_t *info, void *context) -{ received_all = 1; } @@ -68,7 +60,7 @@ main () char *bufs; struct sigaction action; struct sigevent event; - struct timespec ts = {0, 10000000}; /* 10 ms */ + struct timespec ts = {0, 1000}; /* 10 ms */ int errors = 0; int ret; int err; @@ -119,29 +111,18 @@ main () aiocbs[i]->aio_buf = &bufs[i*BUF_SIZE]; aiocbs[i]->aio_nbytes = BUF_SIZE; aiocbs[i]->aio_lio_opcode = LIO_READ; - - /* Use SIRTMIN+1 for individual completions */ - aiocbs[i]->aio_sigevent.sigev_notify = SIGEV_SIGNAL; - aiocbs[i]->aio_sigevent.sigev_signo = SIGRTMIN+1; - aiocbs[i]->aio_sigevent.sigev_value.sival_int = i; } - /* Use SIGRTMIN+2 for list completion */ + /* Use SIGRTMIN + 1 for list completion */ event.sigev_notify = SIGEV_SIGNAL; - event.sigev_signo = SIGRTMIN+2; + event.sigev_signo = SIGRTMIN + 1; event.sigev_value.sival_ptr = NULL; - /* Setup handler for individual operation completion */ - action.sa_sigaction = sigrt1_handler; - sigemptyset(&action.sa_mask); - action.sa_flags = SA_SIGINFO|SA_RESTART; - sigaction(SIGRTMIN+1, &action, NULL); - /* Setup handler for list completion */ - action.sa_sigaction = sigrt2_handler; + action.sa_sigaction = sigrt1_handler; sigemptyset(&action.sa_mask); action.sa_flags = SA_SIGINFO|SA_RESTART; - sigaction(SIGRTMIN+2, &action, NULL); + sigaction(SIGRTMIN + 1, &action, NULL); /* Setup suspend list */ plist[0] = NULL; @@ -161,7 +142,7 @@ main () } /* Check selected request has not completed yet */ - if (received_selected) { + if (EINPROGRESS != aio_error(aiocbs[WAIT_FOR_AIOCB])) { printf (TNAME " Error : AIOCB %d already completed before suspend\n", WAIT_FOR_AIOCB); for (i=0; i<NUM_AIOCBS; i++) @@ -176,7 +157,7 @@ main () ret = aio_suspend((const struct aiocb **)plist, 2, &ts); /* Check selected request has not completed */ - if (received_selected) { + if (EINPROGRESS != aio_error(aiocbs[WAIT_FOR_AIOCB])) { printf (TNAME " Error : AIOCB %d should not have completed after timed out suspend\n", WAIT_FOR_AIOCB); for (i=0; i<NUM_AIOCBS; i++) @@ -237,4 +218,4 @@ main () printf (TNAME " PASSED\n"); return PTS_PASS; -} \ No newline at end of file +} -- 1.7.1 |