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

tcp: Don't stop refilling socket pool if we find a filled entry

Currently tcp_sock_refill_pool() stops as soon as it finds an entry in the
pool with a valid fd.  This appears to makes sense: we always use fds from
the front of the pool, so if we find a filled one, the rest of the pool
should be filled as well.

However, that's not quite correct.  If a previous refill hit errors trying
to open new sockets, it could leave gaps between blocks of valid fds. We're
going to add some changes that could make that more likely.

So, for robustness, instead skip over the filled entry but still try to
refill the rest of the array.  We expect simply iterating over the pool to
be of small cost compared to even a single system call, so this shouldn't
have much impact.

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:47 +11:00 committed by Stefano Brivio
parent 4e08d9b9c6
commit af303fdbff

2
tcp.c
View File

@ -3014,7 +3014,7 @@ void tcp_sock_refill_pool(const struct ctx *c, int pool[], sa_family_t af)
for (i = 0; i < TCP_SOCK_POOL_SIZE; i++) {
if (pool[i] >= 0)
break;
continue;
pool[i] = tcp_conn_new_sock(c, af);
}