From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NO_DNS_FOR_FROM,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from localhost.localdomain (unknown [182.2.38.99]) by gnuweeb.org (Postfix) with ESMTPSA id 4B70880927; Fri, 2 Sep 2022 01:18:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1662081510; bh=XQBr8PxJ0niB7G2n+280ojDnSSkFXiJIHzjXh7U4PII=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LQMUu2ERYSsCQLMdEFo042bGQMmxXYthZks/6UVw9Lc42VhcKrGiAMQ9fBdRjFEad choCBzLZWR7ZqBhMxqKxj0+M1yj9ZWNznKqzbYhKhi4rHEaNbygAa497iLjZJSUFdA s1jbyIudrOZgFcysJ8umUyfiybVrLud0UkxDwDxjrZEa6NTLLUpdKdtkLYms43AFIv ntMO7dLKzD8lboaaweixhDD5mpc95csF3/p6FfexR/1Bb7mSi43mMz9yfWsfBqAK/K tBlQdr23V/twhrS2xkcpxD0K5Bm0HAYTp0DzCyA87EVJmHV5rZ4dvC0SG4sdsZj6aH N0H53AZf1n+OQ== From: Ammar Faizi To: Jens Axboe Cc: Ammar Faizi , Dylan Yudaken , Facebook Kernel Team , Pavel Begunkov , io-uring Mailing List , GNU/Weeb Mailing List , Kanna Scarlet , Muhammad Rizki Subject: [RESEND PATCH liburing v1 08/12] t/connect: Don't use a static port number Date: Fri, 2 Sep 2022 08:17:48 +0700 Message-Id: <20220902011548.2506938-9-ammar.faizi@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220902011548.2506938-1-ammar.faizi@intel.com> References: <20220902011548.2506938-1-ammar.faizi@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: From: Ammar Faizi 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 Cc: Facebook Kernel Team Cc: Pavel Begunkov Signed-off-by: Ammar Faizi --- 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 @@ -185,29 +185,26 @@ 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