From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 714775A0293 for ; Tue, 23 May 2023 04:25:52 +0200 (CEST) Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4QQJ8B2cjGz4x48; Tue, 23 May 2023 12:25:46 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1684808746; bh=pXqe+2/lUnHyWML1XTIde3+5lwqBgbRrkabHTrSYHUg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lHj8LrJfq280BrEg0+XEPhdYu+VucYnqB359TDcQqJtSRAEUyAVJrG720exocVP8U /P1K31EWHMjY3wTtafO+juWXTjlXxwNC2Vg64BK9trWFZ0x5KjafdR1jAY5KVbrL92 b2h5UcU85J4okoiiPx3pc1c6TyhGfSnOqbLKcPkw= From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH 2/2] test/nstool: Fix fd leak in accept() loop Date: Tue, 23 May 2023 12:25:43 +1000 Message-Id: <20230523022543.623950-3-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230523022543.623950-1-david@gibson.dropbear.id.au> References: <20230523022543.623950-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: O2ZM2B2GBAP6W443URRTNDTKOWKCKSJP X-Message-ID-Hash: O2ZM2B2GBAP6W443URRTNDTKOWKCKSJP X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: nstool loops on accept(), but failed to close the accepted socket fds before continuing on. So, with repeated commands it would eventually die with an EMFILE. Signed-off-by: David Gibson --- test/nstool.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/nstool.c b/test/nstool.c index bca9569..1bdf44e 100644 --- a/test/nstool.c +++ b/test/nstool.c @@ -201,6 +201,8 @@ static void cmd_hold(int argc, char *argv[]) rc = read(afd, &buf, sizeof(buf)); if (rc < 0) die("read(): %s\n", strerror(errno)); + + close(afd); } while (rc == 0); unlink(sockpath); -- 2.40.1