diff options
author | Ulrich Drepper <drepper@redhat.com> | 2003-07-01 03:29:50 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2003-07-01 03:29:50 +0000 |
commit | 3a4d1e1e490a8c98ad8478973936880c3f4af0bd (patch) | |
tree | 0e8a6da9a3d088f573ec96d289b92c23f8683841 /nptl/tst-once3.c | |
parent | 5a8e918dc6809872537f589976cc5b9e9d89131c (diff) | |
download | glibc-3a4d1e1e490a8c98ad8478973936880c3f4af0bd.tar.gz glibc-3a4d1e1e490a8c98ad8478973936880c3f4af0bd.tar.xz glibc-3a4d1e1e490a8c98ad8478973936880c3f4af0bd.zip |
Update.
2003-06-30 Ulrich Drepper <drepper@redhat.com> * sysdeps/unix/sysv/linux/i386/pthread_once.S (__pthread_once): Use correct cleanup handler registration. Add unwind info. * tst-once3.c: Add cleanup handler and check it is called. * tst-once4.c: Likewise. * tst-oncex3.c: New file. * tst-oncex4.c: New file. * Makefile: Add rules to build and run tst-oncex3 and tst-oncex4.
Diffstat (limited to 'nptl/tst-once3.c')
-rw-r--r-- | nptl/tst-once3.c | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/nptl/tst-once3.c b/nptl/tst-once3.c index 802864c09a..43b354a391 100644 --- a/nptl/tst-once3.c +++ b/nptl/tst-once3.c @@ -33,6 +33,7 @@ static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER; static pthread_barrier_t bar; static int global; +static int cl_called; static void once_handler1 (void) @@ -42,6 +43,7 @@ once_handler1 (void) puts ("once_handler1: mutex_lock failed"); exit (1); } + puts ("once_handler1: locked"); int r = pthread_barrier_wait (&bar); if (r != 0 && r!= PTHREAD_BARRIER_SERIAL_THREAD) @@ -53,6 +55,7 @@ once_handler1 (void) pthread_cond_wait (&cond, &mut); /* We should never get here. */ + exit (42); } static void @@ -62,11 +65,22 @@ once_handler2 (void) } +static void +cl (void *arg) +{ + cl_called = 1; +} + + static void * tf (void *arg) { + pthread_cleanup_push (cl, NULL) + pthread_once (&once, once_handler1); + pthread_cleanup_pop (0); + /* We should never get here. */ puts ("pthread_once in tf returned"); exit (1); @@ -81,40 +95,41 @@ do_test (void) if (pthread_barrier_init (&bar, NULL, 2) != 0) { puts ("barrier_init failed"); - exit (1); + return 1; } if (pthread_create (&th, NULL, tf, NULL) != 0) { puts ("first create failed"); - exit (1); + return 1; } int r = pthread_barrier_wait (&bar); if (r != 0 && r!= PTHREAD_BARRIER_SERIAL_THREAD) { puts ("barrier_wait failed"); - exit (1); + return 1; } if (pthread_mutex_lock (&mut) != 0) { puts ("mutex_lock failed"); - exit (1); + return 1; } /* We unlock the mutex so that we catch the case where the pthread_cond_wait call incorrectly resumes and tries to get the mutex. */ if (pthread_mutex_unlock (&mut) != 0) { puts ("mutex_unlock failed"); - exit (1); + return 1; } /* Cancel the thread. */ + puts ("going to cancel"); if (pthread_cancel (th) != 0) { puts ("cancel failed"); - exit (1); + return 1; } void *result; @@ -122,7 +137,13 @@ do_test (void) if (result != PTHREAD_CANCELED) { puts ("join didn't return PTHREAD_CANCELED"); - exit (1); + return 1; + } + + if (cl_called != 1) + { + puts ("cleanup handler not called"); + return 1; } pthread_once (&once, once_handler2); @@ -130,7 +151,7 @@ do_test (void) if (global != 1) { puts ("global still 0"); - exit (1); + return 1; } return 0; |