]> git.sur5r.net Git - openldap/commitdiff
ITS#8505 Protect parent from fork()-pthread_exit()
authorHallvard Furuseth <hallvard@openldap.org>
Tue, 27 Sep 2016 05:03:40 +0000 (07:03 +0200)
committerHallvard Furuseth <hallvard@openldap.org>
Thu, 15 Dec 2016 21:27:33 +0000 (22:27 +0100)
libraries/liblmdb/mdb.c

index 36094bf4f3b042a5d6006bd5b5498b782c36ae60..e2f1bbca1d23c19cf81b2db36a36f86402f2c6ab 100644 (file)
@@ -4429,7 +4429,11 @@ mdb_env_reader_dest(void *ptr)
 {
        MDB_reader *reader = ptr;
 
-       reader->mr_pid = 0;
+#ifndef _WIN32
+       if (reader->mr_pid == getpid()) /* catch pthread_exit() in child process */
+#endif
+               /* We omit the mutex, so do this atomically (i.e. skip mr_txnid) */
+               reader->mr_pid = 0;
 }
 
 #ifdef _WIN32