about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-07-25 07:56:33 +0000
committerUlrich Drepper <drepper@redhat.com>2003-07-25 07:56:33 +0000
commit7b787f8516c039ed56b1bc3f511eb1165526061b (patch)
tree23522977702d05b9e5aacbcaf115ff165841b404
parent02ade8d6b0058becfb8d3156e8b9cc3519bfb4bb (diff)
downloadglibc-7b787f8516c039ed56b1bc3f511eb1165526061b.tar.gz
glibc-7b787f8516c039ed56b1bc3f511eb1165526061b.tar.xz
glibc-7b787f8516c039ed56b1bc3f511eb1165526061b.zip
Update.
2003-07-24  Jakub Jelinek  <jakub@redhat.com>

	* 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.
-rw-r--r--ChangeLog6
-rw-r--r--elf/rtld-Rules2
-rw-r--r--nptl/ChangeLog7
-rw-r--r--nptl/tst-cancel17.c41
-rw-r--r--sysdeps/pthread/aio_cancel.c8
5 files changed, 49 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 44e8d6333b..7779a7dc38 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2003-07-24  Jakub Jelinek  <jakub@redhat.com>
+
+	* 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.
+
 2003-07-24  Ulrich Drepper  <drepper@redhat.com>
 
 	* timezone/zic.c (rpytime): Replace cheap overflow check with a
diff --git a/elf/rtld-Rules b/elf/rtld-Rules
index a1515e744d..ac96f728d9 100644
--- a/elf/rtld-Rules
+++ b/elf/rtld-Rules
@@ -31,7 +31,7 @@ rtld-all:
 ifeq ($(subdir),elf)
 
 ifndef rtld-subdirs
-error This is makefile is a subroutine of elf/Makefile not to be used directly
+error This makefile is a subroutine of elf/Makefile not to be used directly
 endif
 
 include ../Makeconfig
diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index 00f9062f1f..0f6bea50e2 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,3 +1,10 @@
+2003-07-25  Jakub Jelinek  <jakub@redhat.com>
+
+	* tst-cancel17.c (do_test): Check if aio_cancel failed.
+	Don't reuse struct aiocb A if it failed.
+	Write fpathconf (fds[1], _PC_PIPE_BUF) + 2 bytes using aio_write,
+	not just one byte, as that does not block.
+
 2003-07-22  Jakub Jelinek  <jakub@redhat.com>
 
 	* sysdeps/pthread/unwind-resume.c: New file.
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;
     }
 
diff --git a/sysdeps/pthread/aio_cancel.c b/sysdeps/pthread/aio_cancel.c
index b2f7be1935..a37b2c7896 100644
--- a/sysdeps/pthread/aio_cancel.c
+++ b/sysdeps/pthread/aio_cancel.c
@@ -60,7 +60,13 @@ aio_cancel (fildes, aiocbp)
     {
       /* If the AIO request is not for this descriptor it has no value
 	 to look for the request block.  */
-      if (aiocbp->aio_fildes == fildes)
+      if (aiocbp->aio_fildes != fildes)
+	{
+	  pthread_mutex_unlock (&__aio_requests_mutex);
+	  __set_errno (EINVAL);
+	  return -1;
+	}
+      else if (aiocbp->__error_code == EINPROGRESS)
 	{
 	  struct requestlist *last = NULL;