1
0
mirror of https://passt.top/passt synced 2024-07-04 08:52:40 +00:00

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>
This commit is contained in:
David Gibson 2024-02-19 18:56:51 +11:00 committed by Stefano Brivio
parent fe27ebce5c
commit e5e6f29459

8
tcp.c
View File

@ -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;