]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - nptl/tst-cancel20.c
Add per-thread cache to malloc
[thirdparty/glibc.git] / nptl / tst-cancel20.c
index 7e9199fe58a3a0641fc8ced379df44ec3f5f3eeb..89cf9eaadab9d6739696fba124ec186381f0da02 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2003-2017 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
 
@@ -145,12 +145,6 @@ do_one_test (void)
       return 1;
     }
 
-  /* This will cause the read in the child to return.  */
-  close (fd[0]);
-  close (fd[1]);
-  close (fd[2]);
-  close (fd[3]);
-
   void *ret;
   if (pthread_join (th, &ret) != 0)
     {
@@ -170,6 +164,15 @@ do_one_test (void)
       return 1;
     }
 
+  /* The pipe closing must be issued after the cancellation handling to avoid
+     a race condition where the cancellation runs after both pipe ends are
+     closed.  In this case the read syscall returns EOF and the cancellation
+     must not act.  */
+  close (fd[0]);
+  close (fd[1]);
+  close (fd[2]);
+  close (fd[3]);
+
   return 0;
 }
 
@@ -227,6 +230,7 @@ do_test (void)
   if (do_one_test ())
     return 1;
 
+#ifdef SA_SIGINFO
   sa.sa_sigaction = (void (*)(int, siginfo_t *, void *)) sh;
   sigemptyset (&sa.sa_mask);
   sa.sa_flags = SA_SIGINFO;
@@ -254,6 +258,7 @@ do_test (void)
   puts ("sa_flags = SA_SIGINFO|SA_ONSTACK test");
   if (do_one_test ())
     return 1;
+#endif
 
   return 0;
 }