diff options
author | Hallvard Furuseth <hallvard@openldap.org> | 2016-10-20 09:51:22 +0200 |
---|---|---|
committer | Hallvard Furuseth <hallvard@openldap.org> | 2016-12-13 18:50:45 +0100 |
commit | e539654051a6300997be7420e67b31d08c87aa90 (patch) | |
tree | 03f4421ae4da5ba6e2862894d84fa5647a929ba7 | |
parent | 3e7a8e26e6a06ef34fcb460b608c6e65f688b9a6 (diff) | |
download | lmdb-e539654051a6300997be7420e67b31d08c87aa90.tar.gz lmdb-e539654051a6300997be7420e67b31d08c87aa90.tar.bz2 lmdb-e539654051a6300997be7420e67b31d08c87aa90.zip |
ITS#8504 Fix prev commit: mc_error, #ifdef SIGPIPE
Never clear mc_error, we could lose a failure in the other thread.
-rw-r--r-- | libraries/liblmdb/mdb.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index b87e576..9e0f907 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -9787,17 +9787,17 @@ mdb_env_copythr(void *arg) #define DO_WRITE(rc, fd, ptr, w2, len) rc = WriteFile(fd, ptr, w2, &len, NULL) #else int len; - sigset_t set; #define DO_WRITE(rc, fd, ptr, w2, len) len = write(fd, ptr, w2); rc = (len >= 0) - +#ifdef SIGPIPE + sigset_t set; sigemptyset(&set); sigaddset(&set, SIGPIPE); + if ((rc = pthread_sigmask(SIG_BLOCK, &set, NULL)) != 0) + my->mc_error = rc; +#endif #endif pthread_mutex_lock(&my->mc_mutex); -#ifndef _WIN32 - my->mc_error = pthread_sigmask(SIG_BLOCK, &set, NULL); -#endif for(;;) { while (!my->mc_new) pthread_cond_wait(&my->mc_cond, &my->mc_mutex); @@ -9811,8 +9811,11 @@ again: DO_WRITE(rc, my->mc_fd, ptr, wsize, len); if (!rc) { rc = ErrCode(); -#ifndef _WIN32 +#if defined(SIGPIPE) && !defined(_WIN32) if (rc == EPIPE) { + /* Collect the pending SIGPIPE, otherwise at least OS X + * gives it to the process on thread-exit (ITS#8504). + */ int tmp; sigwait(&set, &tmp); } |