From: Cyril Hrubis <chrubis@suse.cz>
To: Bian Naimeng <biannm@cn.fujitsu.com>
Cc: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [POSIX][PATCH 2/2][V2]Use aio_error instead signal hander at aio_suspend/4-1
Date: Thu, 18 Nov 2010 19:34:51 +0100 [thread overview]
Message-ID: <20101118183451.GD19296@saboteur.suse.cz> (raw)
In-Reply-To: <4CDCA2D6.1020106@cn.fujitsu.com>
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 <biannm@cn.fujitsu.com>
>
> ---
> .../conformance/interfaces/aio_suspend/4-1.c | 62 ++++++--------------
> 1 files changed, 18 insertions(+), 44 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..bb90234 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,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}; /* 1 us */
> int errors = 0;
> int ret;
> int err;
> @@ -121,30 +113,19 @@ 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 */
> + /* 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];
> @@ -153,7 +134,8 @@ main ()
> ret = lio_listio(LIO_NOWAIT, aiocbs, NUM_AIOCBS, &event);
>
> 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<NUM_AIOCBS; i++)
> free (aiocbs[i]);
> free (bufs);
Once again, space here.
> @@ -163,9 +145,10 @@ main ()
> }
>
> /* Check selected request has not completed yet */
> - if (received_selected) {
> - printf (TNAME " Error : AIOCB %d already completed before suspend\n",
> - WAIT_FOR_AIOCB);
> + err = aio_error(aiocbs[WAIT_FOR_AIOCB]);
> + if (err != EINPROGRESS) {
> + printf (TNAME " Error : AIOCB %d should not have completed "
> + "before suspend\n", WAIT_FOR_AIOCB);
> for (i=0; i<NUM_AIOCBS; i++)
> free (aiocbs[i]);
> free (bufs);
...
> exit(PTS_FAIL);
> }
Spaces after printf and free.
And the same problem with relying on AIO operation not finished yet. So
I propose to change this PTS_FAIL to PTS_UNRESOLVED.
> @@ -177,21 +160,10 @@ main ()
> /* Suspend on selected request */
> ret = aio_suspend((const struct aiocb **)plist, 2, &ts);
Useless cast.
> - /* 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<NUM_AIOCBS; 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<NUM_AIOCBS; i++)
> free (aiocbs[i]);
> free (bufs);
> @@ -200,9 +172,11 @@ main ()
> exit (PTS_FAIL);
> }
Spaces after free and exit.
> - if (errno != EAGAIN) {
> - printf (TNAME " aio_suspend() should set errno to EAGAIN: %d (%s)\n",
> - errno, strerror (errno));
> + /* Check selected request has not completed */
> + err = aio_error(aiocbs[WAIT_FOR_AIOCB]);
> + if (err != EINPROGRESS) {
> + printf (TNAME " Error : AIOCB %d should not have completed "
> + "after timed out suspend\n", WAIT_FOR_AIOCB);
> for (i=0; i<NUM_AIOCBS; i++)
> free (aiocbs[i]);
> free (bufs);
And here spaces after printf and free.
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
Spend less time writing and rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next prev parent reply other threads:[~2010-11-18 18:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-11 3:09 [LTP] [POSIX][PATCH 0/2]aio_suspend may be interrupted by completion signal Bian Naimeng
2010-11-11 3:17 ` [LTP] [POSIX][PATCH 1/2]Use aio_error instead signal hander at aio_suspend/1-1 Bian Naimeng
2010-11-11 14:51 ` Cyril Hrubis
[not found] ` <4CDCA278.8080301@cn.fujitsu.com>
2010-11-18 18:29 ` [LTP] [POSIX][PATCH 1/2][v2]Use " Cyril Hrubis
[not found] ` <AANLkTikbndT97R8edA769vX_JgaaawTS5htipuA3Qb0q@mail.gmail.com>
2010-11-25 19:24 ` Cyril Hrubis
2010-11-11 3:18 ` [LTP] [POSIX][PATCH 2/2]Use aio_error instead signal hander at aio_suspend/4-1 Bian Naimeng
2010-11-11 15:00 ` Cyril Hrubis
[not found] ` <4CDCA2D6.1020106@cn.fujitsu.com>
2010-11-18 18:34 ` Cyril Hrubis [this message]
2010-11-11 14:39 ` [LTP] [POSIX][PATCH 0/2]aio_suspend may be interrupted by completion signal Cyril Hrubis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101118183451.GD19296@saboteur.suse.cz \
--to=chrubis@suse.cz \
--cc=biannm@cn.fujitsu.com \
--cc=ltp-list@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox