From 7b787f8516c039ed56b1bc3f511eb1165526061b Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 25 Jul 2003 07:56:33 +0000 Subject: Update. 2003-07-24 Jakub Jelinek * sysdeps/pthread/aio_cancel.c (aio_cancel): Return AIO_ALLDONE if aiocbp != NULL and has already completed. Return -1/EINVAL if aiocbp->aio_fildes does not match fildes. --- nptl/tst-cancel17.c | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) (limited to 'nptl/tst-cancel17.c') diff --git a/nptl/tst-cancel17.c b/nptl/tst-cancel17.c index 861ca5ea69..d1734a2e5f 100644 --- a/nptl/tst-cancel17.c +++ b/nptl/tst-cancel17.c @@ -98,7 +98,7 @@ do_test (void) return 1; } - struct aiocb a; + struct aiocb a, a2, *ap; char mem[1]; memset (&a, '\0', sizeof (a)); a.aio_fildes = fds[0]; @@ -214,22 +214,37 @@ do_test (void) } puts ("in-time cancellation succeeded"); - aio_cancel (fds[0], &a); + + ap = &a; + if (aio_cancel (fds[0], &a) != AIO_CANCELED) + { + puts ("aio_cancel failed"); + /* If aio_cancel failed, we cannot reuse aiocb a. */ + ap = &a2; + } cl_called = 0; - memset (&a, '\0', sizeof (a)); - a.aio_fildes = fds[1]; - a.aio_buf = mem; - a.aio_nbytes = sizeof (mem); - if (aio_write (&a) != 0) + size_t len2 = fpathconf (fds[1], _PC_PIPE_BUF) + sizeof (mem) + 1; + char *mem2 = malloc (len2); + if (mem2 == NULL) + { + puts ("could not allocate memory for pipe write"); + return 1; + } + + memset (ap, '\0', sizeof (*ap)); + ap->aio_fildes = fds[1]; + ap->aio_buf = mem2; + ap->aio_nbytes = len2; + if (aio_write (ap) != 0) { puts ("aio_write failed"); return 1; } - if (pthread_create (&th, NULL, tf, &a) != 0) + if (pthread_create (&th, NULL, tf, ap) != 0) { puts ("3rd create failed"); return 1; @@ -262,18 +277,18 @@ do_test (void) if (cl_called == 0) { - printf ("tf cleanup handler not called\n"); + puts ("tf cleanup handler not called"); return 1; } if (cl_called > 1) { - printf ("tf cleanup handler called more than once\n"); + puts ("tf cleanup handler called more than once"); return 1; } cl_called = 0; - if (pthread_create (&th, NULL, tf2, &a) != 0) + if (pthread_create (&th, NULL, tf2, ap) != 0) { puts ("4th create failed"); return 1; @@ -306,12 +321,12 @@ do_test (void) if (cl_called == 0) { - printf ("tf2 cleanup handler not called\n"); + puts ("tf2 cleanup handler not called"); return 1; } if (cl_called > 1) { - printf ("tf2 cleanup handler called more than once\n"); + puts ("tf2 cleanup handler called more than once"); return 1; } -- cgit 1.4.1