Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/libexec/ld.elf_so Avoid a race condition between dlclo...



details:   https://anonhg.NetBSD.org/src/rev/8d8471f00e4d
branches:  trunk
changeset: 825557:8d8471f00e4d
user:      joerg <joerg%NetBSD.org@localhost>
date:      Fri Jul 21 16:39:20 2017 +0000

description:
Avoid a race condition between dlclose and thread termination.

diffstat:

 tests/libexec/ld.elf_so/h_thread_local_dtor.c |  9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diffs (26 lines):

diff -r e5599ac1207e -r 8d8471f00e4d tests/libexec/ld.elf_so/h_thread_local_dtor.c
--- a/tests/libexec/ld.elf_so/h_thread_local_dtor.c     Fri Jul 21 12:48:01 2017 +0000
+++ b/tests/libexec/ld.elf_so/h_thread_local_dtor.c     Fri Jul 21 16:39:20 2017 +0000
@@ -75,10 +75,6 @@
        pthread_cond_wait(&cond1, &mutex);
        pthread_mutex_unlock(&mutex);
 
-       pthread_mutex_lock(&mutex);
-       pthread_cond_signal(&cond2);
-       pthread_mutex_unlock(&mutex);
-
        printf("before dlclose\n");
        dlclose(dso);
        printf("after dlclose\n");
@@ -86,6 +82,11 @@
        if (dso == NULL)
                errx(1, "%s", dlerror());
        dlclose(dso);
+
+       pthread_mutex_lock(&mutex);
+       pthread_cond_signal(&cond2);
+       pthread_mutex_unlock(&mutex);
+
        if (pthread_join(thread, NULL))
                err(1, "pthread_join");
        return 0;



Home | Main Index | Thread Index | Old Index