]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - nptl/tst-cond25.c
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / nptl / tst-cond25.c
index d80d8f7e7626d887ca996373eef64e9d69e83dd8..ff676a87e0790bd5428db870e8903a0498b39d69 100644 (file)
@@ -1,6 +1,6 @@
 /* Verify that condition variables synchronized by PI mutexes don't hang on
    on cancellation.
-   Copyright (C) 2012-2015 Free Software Foundation, Inc.
+   Copyright (C) 2012-2018 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -40,7 +40,15 @@ pthread_cond_t cond;
 
 void cleanup (void *u)
 {
-  /* pthread_cond_wait should always return with the mutex locked.  */
+  /* pthread_cond_wait should always return with the mutex locked.  The
+     pthread_mutex_unlock implementation does not actually check whether we
+     own the mutex for several mutex kinds, so check this explicitly.  */
+  int ret = pthread_mutex_trylock (&mutex);
+  if (ret != EDEADLK && ret != EBUSY)
+    {
+      printf ("mutex not locked in cleanup %d\n", ret);
+      abort ();
+    }
   if (pthread_mutex_unlock (&mutex))
     abort ();
 }