aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2024-02-19 18:56:51 +1100
committerStefano Brivio <sbrivio@redhat.com>2024-02-27 12:53:30 +0100
commite5e6f2945977f551ec6958df7ab1892086551896 (patch)
tree4148843fbcec2ff31bc1afb422f52f86578c7667
parentfe27ebce5c59c7fc684c5affa6ce27fdc32d362d (diff)
downloadpasst-e5e6f2945977f551ec6958df7ab1892086551896.tar
passt-e5e6f2945977f551ec6958df7ab1892086551896.tar.gz
passt-e5e6f2945977f551ec6958df7ab1892086551896.tar.bz2
passt-e5e6f2945977f551ec6958df7ab1892086551896.tar.lz
passt-e5e6f2945977f551ec6958df7ab1892086551896.tar.xz
passt-e5e6f2945977f551ec6958df7ab1892086551896.tar.zst
passt-e5e6f2945977f551ec6958df7ab1892086551896.zip
tcp: Don't store errnos in socket pool
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> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--tcp.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/tcp.c b/tcp.c
index 40a79b4..7be8355 100644
--- a/tcp.c
+++ b/tcp.c
@@ -3039,11 +3039,15 @@ 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;