aboutsummaryrefslogtreecommitdiff
path: root/nptl
diff options
context:
space:
mode:
Diffstat (limited to 'nptl')
-rw-r--r--nptl/ChangeLog5
-rw-r--r--nptl/tst-cond22.c25
2 files changed, 21 insertions, 9 deletions
diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index c269f3d..6c7fd49 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,3 +1,8 @@
+2006-09-12 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-cond22.c (tf): Slight changes to the pthread_cond_wait use
+ to guarantee the thread is always canceled.
+
2006-09-08 Jakub Jelinek <jakub@redhat.com>
* tst-cond22.c: Include pthread.h instead of pthreadP.h.
diff --git a/nptl/tst-cond22.c b/nptl/tst-cond22.c
index 1094c09..e7c8d01 100644
--- a/nptl/tst-cond22.c
+++ b/nptl/tst-cond22.c
@@ -30,17 +30,24 @@ tf (void *arg)
exit (1);
}
pthread_cleanup_push (cl, NULL);
- if (pthread_cond_wait (&c, &m) != 0)
- {
- printf ("%s: cond_wait failed\n", __func__);
- exit (1);
+ /* We have to loop here because the cancellation might come after
+ the cond_wait call left the cancelable area and is then waiting
+ on the mutex. In this case the beginning of the second cond_wait
+ call will cause the cancellation to happen. */
+ while (1)
+ {
+ if (pthread_cond_wait (&c, &m) != 0)
+ {
+ printf ("%s: cond_wait failed\n", __func__);
+ exit (1);
+ }
+ if (pthread_mutex_unlock (&m) != 0)
+ {
+ printf ("%s: mutex_unlock failed\n", __func__);
+ exit (1);
+ }
}
pthread_cleanup_pop (0);
- if (pthread_mutex_unlock (&m) != 0)
- {
- printf ("%s: mutex_unlock failed\n", __func__);
- exit (1);
- }
return NULL;
}