mirror of
https://github.com/isar/libmdbx.git
synced 2024-10-30 11:29:19 +08:00
mdbx: restore SIGPIPE hushing in the db-copy-thread.
This commit is contained in:
parent
e7ee0bc762
commit
98a8fbdc7a
23
src/mdbx.c
23
src/mdbx.c
@ -8491,6 +8491,16 @@ static THREAD_RESULT __cold THREAD_CALL mdbx_env_copythr(void *arg) {
|
|||||||
mdbx_copy *my = arg;
|
mdbx_copy *my = arg;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
int toggle = 0, wsize;
|
int toggle = 0, wsize;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
#if defined(SIGPIPE) && !defined(_WIN32) && !defined(_WIN64)
|
||||||
|
sigset_t set;
|
||||||
|
sigemptyset(&set);
|
||||||
|
sigaddset(&set, SIGPIPE);
|
||||||
|
rc = pthread_sigmask(SIG_BLOCK, &set, NULL);
|
||||||
|
if (rc != 0)
|
||||||
|
my->mc_error = rc;
|
||||||
|
#endif
|
||||||
|
|
||||||
mdbx_condmutex_lock(&my->mc_condmutex);
|
mdbx_condmutex_lock(&my->mc_condmutex);
|
||||||
while (!my->mc_error) {
|
while (!my->mc_error) {
|
||||||
@ -8502,9 +8512,18 @@ static THREAD_RESULT __cold THREAD_CALL mdbx_env_copythr(void *arg) {
|
|||||||
ptr = my->mc_wbuf[toggle];
|
ptr = my->mc_wbuf[toggle];
|
||||||
again:
|
again:
|
||||||
if (wsize > 0 && !my->mc_error) {
|
if (wsize > 0 && !my->mc_error) {
|
||||||
int rc = mdbx_write(my->mc_fd, ptr, wsize);
|
rc = mdbx_write(my->mc_fd, ptr, wsize);
|
||||||
if (rc != MDBX_SUCCESS)
|
if (rc != MDBX_SUCCESS) {
|
||||||
|
#if defined(SIGPIPE) && !defined(_WIN32) && !defined(_WIN64)
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
my->mc_error = rc;
|
my->mc_error = rc;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If there's an overflow page tail, write it too */
|
/* If there's an overflow page tail, write it too */
|
||||||
|
Loading…
Reference in New Issue
Block a user