summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFengqi Li <lifengqi@inspur.com>2022-09-30 09:09:28 +0800
committerIlya Maximets <i.maximets@ovn.org>2022-10-06 22:05:15 +0200
commit62628a85e57f19fece48f5562652c0ef17b113c1 (patch)
tree57ecdbb5f8e1ce3977ae94a4aef43d872bc2db10
parent40bba6eeb2cef7d12164a2f1b3e972141c57e0da (diff)
downloadopenvswitch-62628a85e57f19fece48f5562652c0ef17b113c1.tar.gz
daemon-unix: Fix file descriptor leak when monitor restarts child.
When segmentation fault occurred in ovn-northd, monitor will try to restart the ovn-northd daemon process every 10s. Assume the following scenarios: There is a segmentation fault and the ovn-northd daemon process does not restart properly every time. New fds are created each time the ovn-northd daemon process is restarted by the monitor process, but old fds(fd[0]) owned by the monitor process was not closed properly. One pipe leak for each restart of the ovn-northd daemon process. After a long time file descriptors were exhausted. Fixes: e2ed6fbeb18c ("fatal-signal: Catch SIGSEGV and print backtrace.") Signed-off-by: Fengqi Li <lifengqi@inspur.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
-rw-r--r--lib/daemon-unix.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/daemon-unix.c b/lib/daemon-unix.c
index 34d45b82a..31db2d2c7 100644
--- a/lib/daemon-unix.c
+++ b/lib/daemon-unix.c
@@ -393,6 +393,8 @@ monitor_daemon(pid_t daemon_pid)
}
log_received_backtrace(daemonize_fd);
+ close(daemonize_fd);
+ daemonize_fd = -1;
/* Throttle restarts to no more than once every 10 seconds. */
if (time(NULL) < last_restart + 10) {