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 AD92D5A0283 for ; Mon, 19 Feb 2024 08:57:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1708329414; bh=35VQqtCFUDzPq453sHkuIOwnjX8ckq1aY7lo5+DpYgQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eixJ9UJi/nZMeMTQYs1/qYa/gqcT5EtmCoZ/w1SwBm77JCRobTsTskqPTE4C72/7N VBrC6ZvRtutKRxrSVKcrXF7J1kx68k+M5O1Zkaf8g1DjuqtCxSffhW7TWtbdjXVT0y 2xaFkASH7okzkrylQKTz0/mdM07D5EKFidPgSLg6LeE5+2izCqwlKDiRNK1EW5rgXi K/XoWrYdjCgWegyyO0AX2BGgfTtTO1Nsnfv+ORAEaRx0Z5G5+udDVzstye5QXLcGpR 5WB9k4U/+d9Wqj/rDHyNKNHyFdx+npTGKivfbse7bbPjzpsLtbccl7weGmI3CjAVnb fh3fM5rDcrojg== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4TdZck3mFnz4x1s; Mon, 19 Feb 2024 18:56:54 +1100 (AEDT) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH 6/6] tcp: Don't store errnos in socket pool Date: Mon, 19 Feb 2024 18:56:51 +1100 Message-ID: <20240219075651.1360229-7-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240219075651.1360229-1-david@gibson.dropbear.id.au> References: <20240219075651.1360229-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: RAIKEHAK7MNH3KHNJWXSGIXFGH6C24G6 X-Message-ID-Hash: RAIKEHAK7MNH3KHNJWXSGIXFGH6C24G6 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: If tcp_sock_refill_pool() gets an error opening new sockets, it stores the negative errno of that error in the socket pool. This isn't especially useful: * It's inconsistent with the initial state of the pool (all -1) * It's inconsistent with the state of an entry that was valid and was then consumed (also -1) * By the time we did anything with this error code, it's now far removed from the situation in which the error occurred, making it difficult to report usefully We now have error reporting closer to when failures happen on the refill paths, so just leave a pool slot we can't fill as -1. Signed-off-by: David Gibson --- tcp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tcp.c b/tcp.c index 34e32641..27865691 100644 --- a/tcp.c +++ b/tcp.c @@ -3039,11 +3039,13 @@ int tcp_sock_refill_pool(const struct ctx *c, int pool[], sa_family_t af) int i; for (i = 0; i < TCP_SOCK_POOL_SIZE; i++) { + int fd; if (pool[i] >= 0) continue; - if ((pool[i] = tcp_conn_new_sock(c, af)) < 0) - return pool[i]; + if ((fd = tcp_conn_new_sock(c, af)) < 0) + return fd; + pool[i] = fd; } return 0; -- 2.43.2