From: Lorenz Bauer Date: Thu, 20 Oct 2016 07:51:22 +0000 (+0200) Subject: ITS#8504 mdb_env_copyfd2(): Don't abort on SIGPIPE X-Git-Tag: LMDB_0.9.19~7 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=894e88bf895529b2f4682f74c7a8c69a0c61cc00;p=openldap ITS#8504 mdb_env_copyfd2(): Don't abort on SIGPIPE Return EPIPE instead. --- diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index 32349dffe9..33c699883c 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -129,6 +129,7 @@ typedef SSIZE_T ssize_t; #ifndef _WIN32 #include +#include #ifdef MDB_USE_POSIX_SEM # define MDB_USE_HASH 1 #include @@ -8995,10 +8996,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) + + sigemptyset(&set); + sigaddset(&set, SIGPIPE); #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); @@ -9012,6 +9020,12 @@ again: DO_WRITE(rc, my->mc_fd, ptr, wsize, len); if (!rc) { rc = ErrCode(); +#ifndef _WIN32 + if (rc == EPIPE) { + int tmp; + sigwait(&set, &tmp); + } +#endif break; } else if (len > 0) { rc = MDB_SUCCESS;