aboutgitcodebugslistschat
path: root/tcp.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2022-03-25 11:24:23 +0100
committerStefano Brivio <sbrivio@redhat.com>2022-03-29 15:35:38 +0200
commit415ccf6116c496aab173ee9548089fe69ccf8f5f (patch)
tree1d8a64b7490f06539b2f1f7f55b840568dddfc63 /tcp.c
parentf41f0416b837925bc8612f45ca58432218ce6707 (diff)
downloadpasst-415ccf6116c496aab173ee9548089fe69ccf8f5f.tar
passt-415ccf6116c496aab173ee9548089fe69ccf8f5f.tar.gz
passt-415ccf6116c496aab173ee9548089fe69ccf8f5f.tar.bz2
passt-415ccf6116c496aab173ee9548089fe69ccf8f5f.tar.lz
passt-415ccf6116c496aab173ee9548089fe69ccf8f5f.tar.xz
passt-415ccf6116c496aab173ee9548089fe69ccf8f5f.tar.zst
passt-415ccf6116c496aab173ee9548089fe69ccf8f5f.zip
tcp, tcp_splice: Use less awkward syntax to swap in/out sockets from pools
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'tcp.c')
-rw-r--r--tcp.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/tcp.c b/tcp.c
index 5d2032f..802d6d8 100644
--- a/tcp.c
+++ b/tcp.c
@@ -2031,13 +2031,12 @@ static uint32_t tcp_seq_init(struct ctx *c, int af, void *addr,
*/
static int tcp_conn_new_sock(struct ctx *c, sa_family_t af)
{
- int *pool = af == AF_INET6 ? init_sock_pool6 : init_sock_pool4, i, s;
+ int *p = af == AF_INET6 ? init_sock_pool6 : init_sock_pool4, i, s = -1;
- for (i = 0; i < TCP_SOCK_POOL_SIZE; i++, pool++) {
- if ((s = *pool) >= 0) {
- *pool = -1;
+ for (i = 0; i < TCP_SOCK_POOL_SIZE; i++, p++) {
+ SWAP(s, *p);
+ if (s >= 0)
break;
- }
}
if (s < 0)