mdbx: adds SIGPIPE suppression inside the env_copy-thread.

Change-Id: Ib7d22b8db7435b396bd997b65ae1d6d5d3431ba9
This commit is contained in:
Leonid Yuriev 2020-10-23 03:22:22 +03:00
parent fed14c8f4c
commit 005517539b
2 changed files with 18 additions and 0 deletions

View File

@ -423,6 +423,7 @@ eot
EOTDONE EOTDONE
EOWNERDEAD EOWNERDEAD
EPERM EPERM
EPIPE
erasevolume erasevolume
EREMOTE EREMOTE
EROFS EROFS
@ -1429,12 +1430,14 @@ sigemptyset
SIGHUP SIGHUP
SIGINT SIGINT
SIGKILL SIGKILL
sigmask
SIGPIPE SIGPIPE
sigprocmask sigprocmask
SIGSEGV SIGSEGV
sigset sigset
SIGTERM SIGTERM
sigusr sigusr
sigwait
singlemode singlemode
singleprocess singleprocess
sizeof sizeof

View File

@ -16198,6 +16198,13 @@ static THREAD_RESULT __cold THREAD_CALL mdbx_env_copythr(void *arg) {
uint8_t *ptr; uint8_t *ptr;
int toggle = 0; int toggle = 0;
#if defined(EPIPE) && !(defined(_WIN32) || defined(_WIN64))
sigset_t sigset;
sigemptyset(&sigset);
sigaddset(&sigset, SIGPIPE);
my->mc_error = pthread_sigmask(SIG_BLOCK, &sigset, NULL);
#endif /* EPIPE */
mdbx_condpair_lock(&my->mc_condpair); mdbx_condpair_lock(&my->mc_condpair);
while (!my->mc_error) { while (!my->mc_error) {
while (!my->mc_new && !my->mc_error) { while (!my->mc_new && !my->mc_error) {
@ -16215,6 +16222,14 @@ static THREAD_RESULT __cold THREAD_CALL mdbx_env_copythr(void *arg) {
if (wsize > 0 && !my->mc_error) { if (wsize > 0 && !my->mc_error) {
int err = mdbx_write(my->mc_fd, ptr, wsize); int err = mdbx_write(my->mc_fd, ptr, wsize);
if (err != MDBX_SUCCESS) { if (err != MDBX_SUCCESS) {
#if defined(EPIPE) && !(defined(_WIN32) || defined(_WIN64))
if (err == EPIPE) {
/* Collect the pending SIGPIPE,
* otherwise at least OS X gives it to the process on thread-exit. */
int unused;
sigwait(&sigset, &unused);
}
#endif /* EPIPE */
my->mc_error = err; my->mc_error = err;
goto bailout; goto bailout;
} }