1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-26 01:49:31 +03:00

ctdb-common: Avoid race between fd and signal events

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13895

In run_proc, there was an implicit assumption that when a process exits,
fd event (pipe between parent and child) would be processed first and
signal event (SIGCHLD for the child) would be processed later.

However, that is not the case.  SIGCHLD can be received asynchronously
any time even when the pipe data has not fully been read.  This causes
run_proc to miss some of the output from child process in tests.

When SIGCHLD is being processed, if the pipe between parent and child is
still open, then do an explict read from the pipe to ensure we read any
data still in the pipe before closing the pipe.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>

Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Fri Apr 12 08:19:29 UTC 2019 on sn-devel-144

(cherry picked from commit 289201277c)

Autobuild-User(v4-9-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-9-test): Mon Apr 15 12:55:46 UTC 2019 on sn-devel-144
This commit is contained in:
Amitay Isaacs
2019-04-09 14:44:04 +10:00
committed by Karolin Seeger
parent d9c47cb86e
commit 945a41d384

View File

@ -295,6 +295,13 @@ again:
proc->result.sig = WTERMSIG(status);
}
/* Confirm that all data has been read from the pipe */
if (proc->fd != -1) {
proc_read_handler(ev, proc->fde, 0, proc);
TALLOC_FREE(proc->fde);
proc->fd = -1;
}
/* Active run_proc request */
if (proc->req != NULL) {
run_proc_done(proc->req);