From: David Gibson <david@gibson.dropbear.id.au>
To: Stefano Brivio <sbrivio@redhat.com>, passt-dev@passt.top
Cc: David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH 6/6] tcp: Don't store errnos in socket pool
Date: Mon, 19 Feb 2024 18:56:51 +1100 [thread overview]
Message-ID: <20240219075651.1360229-7-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20240219075651.1360229-1-david@gibson.dropbear.id.au>
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 <david@gibson.dropbear.id.au>
---
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;
--
@@ -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
next prev parent reply other threads:[~2024-02-19 7:57 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-19 7:56 [PATCH 0/6] tcp: Improve error handling around socket pools David Gibson
2024-02-19 7:56 ` [PATCH 1/6] treewide: Use sa_family_t for address family variables David Gibson
2024-02-19 7:56 ` [PATCH 2/6] tcp: Don't stop refilling socket pool if we find a filled entry David Gibson
2024-02-21 21:08 ` Stefano Brivio
2024-02-21 21:42 ` David Gibson
2024-02-19 7:56 ` [PATCH 3/6] tcp: Stop on first error when refilling socket pools David Gibson
2024-02-19 7:56 ` [PATCH 4/6] tcp, tcp_splice: Issue warnings if unable to refill socket pool David Gibson
2024-02-21 21:09 ` Stefano Brivio
2024-02-21 21:44 ` David Gibson
2024-02-22 12:45 ` Stefano Brivio
2024-02-19 7:56 ` [PATCH 5/6] tcp, tcp_splice: Helpers for getting sockets from the pools David Gibson
2024-02-19 7:56 ` David Gibson [this message]
2024-02-21 21:09 ` [PATCH 6/6] tcp: Don't store errnos in socket pool Stefano Brivio
2024-02-21 21:45 ` David Gibson
2024-02-27 14:22 ` [PATCH 0/6] tcp: Improve error handling around socket pools Stefano Brivio
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240219075651.1360229-7-david@gibson.dropbear.id.au \
--to=david@gibson.dropbear.id.au \
--cc=passt-dev@passt.top \
--cc=sbrivio@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).