[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220902005825.2484023-9-ammar.faizi@intel.com>
Date: Fri, 2 Sep 2022 07:59:42 +0700
From: Ammar Faizi <ammarfaizi2@...weeb.org>
To: Jens Axboe <axboe@...nel.dk>
Cc: Ammar Faizi <ammarfaizi2@...weeb.org>,
Dylan Yudaken <dylany@...com>,
Facebook Kernel Team <kernel-team@...com>,
Pavel Begunkov <asml.silence@...il.com>,
Kanna Scarlet <knscarlet@...weeb.org>,
Muhammad Rizki <kiizuha@...weeb.org>,
GNU/Weeb Mailing List <gwml@...r.gnuweeb.org>,
io-uring Mailing List <io-uring@...r.gnuweeb.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: [PATCH liburing v1 08/12] t/connect: Don't use a static port number
From: Ammar Faizi <ammarfaizi2@...weeb.org>
Don't use a static port number. It might already be in use, resulting
in a test failure. Use an ephemeral port to make this test reliable.
Cc: Dylan Yudaken <dylany@...com>
Cc: Facebook Kernel Team <kernel-team@...com>
Cc: Pavel Begunkov <asml.silence@...il.com>
Signed-off-by: Ammar Faizi <ammarfaizi2@...weeb.org>
---
test/accept.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/test/accept.c b/test/accept.c
index b35ded4..1821faa 100644
--- a/test/accept.c
+++ b/test/accept.c
@@ -184,31 +184,28 @@ static int start_accept_listen(struct sockaddr_in *addr, int port_off,
int32_t val = 1;
ret = setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &val, sizeof(val));
assert(ret != -1);
ret = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
assert(ret != -1);
struct sockaddr_in laddr;
if (!addr)
addr = &laddr;
addr->sin_family = AF_INET;
- addr->sin_port = htons(0x1235 + port_off);
addr->sin_addr.s_addr = inet_addr("127.0.0.1");
-
- ret = bind(fd, (struct sockaddr*)addr, sizeof(*addr));
- assert(ret != -1);
+ assert(!t_bind_ephemeral_port(fd, addr));
ret = listen(fd, 128);
assert(ret != -1);
return fd;
}
static int set_client_fd(struct sockaddr_in *addr)
{
int32_t val;
int fd, ret;
fd = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, IPPROTO_TCP);
--
Ammar Faizi
Powered by blists - more mailing lists