From 6355dade31e35af5527e9139a39fc1e3a5da04fd Mon Sep 17 00:00:00 2001 From: Hallvard Furuseth Date: Tue, 27 Sep 2016 07:03:40 +0200 Subject: [PATCH] ITS#8505 Protect parent from fork()-pthread_exit() --- libraries/liblmdb/mdb.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index 27582ae745..af365b3e25 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -4747,7 +4747,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 -- 2.39.5