diff options
author | Florian Weimer <fweimer@redhat.com> | 2018-07-25 16:31:45 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2018-07-25 16:31:45 +0200 |
commit | d6b8f8470990db2d36b8e50f1055a673fdf1cea0 (patch) | |
tree | 1ba242d4123707db42c35a352ff4e95671e81d64 /nptl/tst-cnd-basic.c | |
parent | 25123a1c5c96429d70e75b85a9749b405909d7f2 (diff) | |
download | glibc-d6b8f8470990db2d36b8e50f1055a673fdf1cea0.tar glibc-d6b8f8470990db2d36b8e50f1055a673fdf1cea0.tar.gz glibc-d6b8f8470990db2d36b8e50f1055a673fdf1cea0.tar.bz2 glibc-d6b8f8470990db2d36b8e50f1055a673fdf1cea0.zip |
C11 threads: Fix timeout and locking issues
Diffstat (limited to 'nptl/tst-cnd-basic.c')
-rw-r--r-- | nptl/tst-cnd-basic.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/nptl/tst-cnd-basic.c b/nptl/tst-cnd-basic.c index 84b7f5f647..eb2fb6a77e 100644 --- a/nptl/tst-cnd-basic.c +++ b/nptl/tst-cnd-basic.c @@ -31,8 +31,14 @@ static mtx_t mutex; static int signal_parent (void) { + /* Acquire the lock so that cnd_signal does not run until + cnd_timedwait has been called. */ + if (mtx_lock (&mutex) != thrd_success) + FAIL_EXIT1 ("mtx_lock failed"); if (cnd_signal (&cond) != thrd_success) FAIL_EXIT1 ("cnd_signal"); + if (mtx_unlock (&mutex) != thrd_success) + FAIL_EXIT1 ("mtx_unlock"); thrd_exit (thrd_success); } @@ -47,6 +53,9 @@ do_test (void) if (mtx_init (&mutex, mtx_plain) != thrd_success) FAIL_EXIT1 ("mtx_init failed"); + if (mtx_lock (&mutex) != thrd_success) + FAIL_EXIT1 ("mtx_lock failed"); + if (thrd_create (&id, (thrd_start_t) signal_parent, NULL) != thrd_success) FAIL_EXIT1 ("thrd_create failed"); @@ -59,6 +68,9 @@ do_test (void) if (thrd_join (id, NULL) != thrd_success) FAIL_EXIT1 ("thrd_join failed"); + if (mtx_unlock (&mutex) != thrd_success) + FAIL_EXIT1 ("mtx_unlock"); + mtx_destroy (&mutex); cnd_destroy (&cond); |