From patchwork Fri Sep 30 01:09:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fengqi Li X-Patchwork-Id: 1684670 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Mdsb51YV7z1yqS for ; Fri, 30 Sep 2022 11:09:51 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 18B91611FC; Fri, 30 Sep 2022 01:09:49 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 18B91611FC X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cAJAn8USFos9; Fri, 30 Sep 2022 01:09:48 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 5200F60B26; Fri, 30 Sep 2022 01:09:43 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 5200F60B26 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0B418C0033; Fri, 30 Sep 2022 01:09:43 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id DBD59C002D for ; Fri, 30 Sep 2022 01:09:41 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id BDCAE4112C for ; Fri, 30 Sep 2022 01:09:41 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org BDCAE4112C X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gE-LGoQFzMqA for ; Fri, 30 Sep 2022 01:09:39 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 6B24A40146 Received: from unicom146.biz-email.net (unicom146.biz-email.net [210.51.26.146]) by smtp2.osuosl.org (Postfix) with ESMTPS id 6B24A40146 for ; Fri, 30 Sep 2022 01:09:37 +0000 (UTC) Received: from ([60.208.111.195]) by unicom146.biz-email.net ((D)) with ASMTP (SSL) id YAN00030; Fri, 30 Sep 2022 09:09:30 +0800 Received: from localhost.localdomain (10.180.204.147) by jtjnmail201603.home.langchao.com (10.100.2.3) with Microsoft SMTP Server id 15.1.2507.12; Fri, 30 Sep 2022 09:09:30 +0800 From: Fengqi Li To: Date: Fri, 30 Sep 2022 09:09:28 +0800 Message-ID: <20220930010928.2419-1-lifengqi@inspur.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Originating-IP: [10.180.204.147] tUid: 202293009093086e7e38ab052e0b8d3fca856c71856f0 X-Abuse-Reports-To: service@corp-email.com Abuse-Reports-To: service@corp-email.com X-Complaints-To: service@corp-email.com X-Report-Abuse-To: service@corp-email.com Cc: Fengqi Li , ovs-dev@openvswitch.org Subject: [ovs-dev] [PATCH v3] daemon-unix: Fix file descriptor leak when monitor restarts child X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" When segmentation fault occured 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 doen not restart properly everytime. New fds are created each time the ovn-northd daemon process is restarted by the monitor process, but old fds(fd[1]) ownered by the monitor process was not closed properly. One pipe leak for each restart of the ovn-northd daemon process. After a long time the OS's pipe was exhausted. Fixes: e2ed6fbeb18c ("fatal-signal: Catch SIGSEGV and print backtrace.") Signed-off-by: Fengqi Li --- lib/daemon-unix.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/daemon-unix.c b/lib/daemon-unix.c index 52f3d4bc6..1a7ba427d 100644 --- a/lib/daemon-unix.c +++ b/lib/daemon-unix.c @@ -396,6 +396,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) {