Return-Path: Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1PGYSS-0004QZ-HZ for ltp-list@lists.sourceforge.net; Thu, 11 Nov 2010 14:49:00 +0000 Date: Thu, 11 Nov 2010 16:00:12 +0100 From: Cyril Hrubis Message-ID: <20101111150012.GC24599@saboteur.suse.cz> References: <4CDB5E53.6070604@cn.fujitsu.com> <4CDB609E.105@cn.fujitsu.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <4CDB609E.105@cn.fujitsu.com> Subject: Re: [LTP] [POSIX][PATCH 2/2]Use aio_error instead signal hander at aio_suspend/4-1 List-Id: Linux Test Project General Discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ltp-list-bounces@lists.sourceforge.net To: Bian Naimeng Cc: ltp-list@lists.sourceforge.net Hi! > aio_suspend may be interrupted by IO request's completion signal, so we > should use aio_error instead signal hander to check whether this request > has complete. > > Signed-off-by: Bian Naimeng > > --- > .../conformance/interfaces/aio_suspend/4-1.c | 65 +++++++------------- > 1 files changed, 23 insertions(+), 42 deletions(-) > > diff --git a/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/4-1.c b/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/4-1.c > index 260c26a..6699ab4 100644 > --- a/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/4-1.c > +++ b/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/4-1.c > @@ -41,18 +41,24 @@ > #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) > +int > +selected_request_status(struct aiocb *paiocb, int expect) > { > - if (info->si_value.sival_int == WAIT_FOR_AIOCB) > - received_selected = 1; > + int err = aio_error(paiocb); > + > + if (err != expect) { > + printf (TNAME " Selected request expect %d[%s], not %d[%s]\n", > + expect, strerror(expect), err, strerror(err)); > + return 0; > + } > + > + return 1; > } > > void > -sigrt2_handler(int signum, siginfo_t *info, void *context) > +sigrt1_handler(int signum, siginfo_t *info, void *context) > { > received_all = 1; > } > @@ -68,7 +74,7 @@ main () > char *bufs; > struct sigaction action; > struct sigevent event; > - struct timespec ts = {0, 10000000}; /* 10 ms */ > + struct timespec ts = {0, 1000}; /* 1 us */ > int errors = 0; > int ret; > int err; > @@ -121,39 +127,28 @@ 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 */ > event.sigev_notify = SIGEV_SIGNAL; > - event.sigev_signo = SIGRTMIN+2; > + event.sigev_signo = SIGRTMIN+1; > event.sigev_value.sival_ptr = NULL; Same here. > - /* Setup handler for individual operation completion */ > + /* Setup handler for list 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; > - sigemptyset(&action.sa_mask); > - action.sa_flags = SA_SIGINFO|SA_RESTART; > - sigaction(SIGRTMIN+2, &action, NULL); > - > /* Setup suspend list */ > plist[0] = NULL; > plist[1] = aiocbs[WAIT_FOR_AIOCB]; > > /* Submit request list */ > ret = lio_listio(LIO_NOWAIT, aiocbs, NUM_AIOCBS, &event); > - Here. > if (ret) { > - printf(TNAME " Error at lio_listio() %d: %s\n", errno, strerror(errno)); > + printf (TNAME " Error at lio_listio() %d: %s\n", > + errno, strerror(errno)); > for (i=0; i free (aiocbs[i]); > free (bufs); > @@ -163,9 +158,7 @@ main () > } > > /* Check selected request has not completed yet */ > - if (received_selected) { > - printf (TNAME " Error : AIOCB %d already completed before suspend\n", > - WAIT_FOR_AIOCB); > + if (!selected_request_status(aiocbs[WAIT_FOR_AIOCB], EINPROGRESS)) { > for (i=0; i free (aiocbs[i]); > free (bufs); And here. > @@ -177,21 +170,10 @@ main () > /* Suspend on selected request */ > ret = aio_suspend((const struct aiocb **)plist, 2, &ts); Useless cast (and I've missed it in comments for previous patch). > - /* Check selected request has not completed */ > - if (received_selected) { > - printf (TNAME " Error : AIOCB %d should not have completed after timed out suspend\n", > - WAIT_FOR_AIOCB); > - for (i=0; i - free (aiocbs[i]); > - free (bufs); > - free (aiocbs); > - close (fd); > - exit (PTS_FAIL); > - } > - > /* timed out aio_suspend should return -1 and set errno to EAGAIN */ > - if (ret != -1) { > - printf (TNAME " aio_suspend() should return -1\n"); > + if (ret != -1 || errno != EAGAIN) { > + printf (TNAME " aio_suspend() should return -1 and set errno " > + "to EAGAIN: %d, %s\n", ret, strerror(errno)); > for (i=0; i free (aiocbs[i]); > free (bufs); > @@ -200,9 +182,8 @@ main () > exit (PTS_FAIL); > } > > - if (errno != EAGAIN) { > - printf (TNAME " aio_suspend() should set errno to EAGAIN: %d (%s)\n", > - errno, strerror (errno)); > + /* Check selected request has not completed */ > + if (!selected_request_status(aiocbs[WAIT_FOR_AIOCB], EINPROGRESS)) { > for (i=0; i free (aiocbs[i]); > free (bufs); I think we should print here, why the test has failed. -- Cyril Hrubis chrubis@suse.cz ------------------------------------------------------------------------------ Centralized Desktop Delivery: Dell and VMware Reference Architecture Simplifying enterprise desktop deployment and management using Dell EqualLogic storage and VMware View: A highly scalable, end-to-end client virtualization framework. Read more! http://p.sf.net/sfu/dell-eql-dev2dev _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list