public inbox for [email protected]
 help / color / mirror / Atom feed
From: Dylan Yudaken <[email protected]>
To: Jens Axboe <[email protected]>,
	Pavel Begunkov <[email protected]>,
	<[email protected]>
Cc: <[email protected]>, Dylan Yudaken <[email protected]>
Subject: [PATCH liburing v2 12/12] shutdown test: bind to ephemeral port
Date: Thu, 1 Sep 2022 02:33:03 -0700	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

This test would occasionally fail if the chosen port was in use. Rather
bind to an ephemeral port which will not be in use.

Signed-off-by: Dylan Yudaken <[email protected]>
---
 test/shutdown.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/test/shutdown.c b/test/shutdown.c
index 14c7407b5492..c584893bdd28 100644
--- a/test/shutdown.c
+++ b/test/shutdown.c
@@ -30,6 +30,7 @@ int main(int argc, char *argv[])
 	int32_t recv_s0;
 	int32_t val = 1;
 	struct sockaddr_in addr;
+	socklen_t addrlen;
 
 	if (argc > 1)
 		return 0;
@@ -44,7 +45,7 @@ int main(int argc, char *argv[])
 	assert(ret != -1);
 
 	addr.sin_family = AF_INET;
-	addr.sin_port = htons((rand() % 61440) + 4096);
+	addr.sin_port = 0;
 	addr.sin_addr.s_addr = inet_addr("127.0.0.1");
 
 	ret = bind(recv_s0, (struct sockaddr*)&addr, sizeof(addr));
@@ -52,6 +53,10 @@ int main(int argc, char *argv[])
 	ret = listen(recv_s0, 128);
 	assert(ret != -1);
 
+	addrlen = (socklen_t)sizeof(addr);
+	assert(!getsockname(recv_s0, (struct sockaddr *)&addr,
+			    &addrlen));
+
 	p_fd[1] = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, IPPROTO_TCP);
 
 	val = 1;
-- 
2.30.2


  parent reply	other threads:[~2022-09-01  9:33 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-01  9:32 [PATCH liburing v2 00/12] Defer taskrun changes Dylan Yudaken
2022-09-01  9:32 ` [PATCH liburing v2 01/12] Copy defer task run definition from kernel Dylan Yudaken
2022-09-01  9:32 ` [PATCH liburing v2 02/12] Add documentation for IORING_SETUP_DEFER_TASKRUN flag Dylan Yudaken
2022-09-01  9:32 ` [PATCH liburing v2 03/12] add io_uring_submit_and_get_events and io_uring_get_events Dylan Yudaken
2022-09-01 18:36   ` Jens Axboe
2022-09-05  8:31     ` Dylan Yudaken
2022-09-01  9:32 ` [PATCH liburing v2 04/12] add a t_probe_defer_taskrun helper function for tests Dylan Yudaken
2022-09-01  9:32 ` [PATCH liburing v2 05/12] update existing tests for defer taskrun Dylan Yudaken
2022-09-01  9:32 ` [PATCH liburing v2 06/12] add a defer-taskrun test Dylan Yudaken
2022-09-01  9:32 ` [PATCH liburing v2 07/12] update io_uring_enter.2 docs for IORING_FEAT_NODROP Dylan Yudaken
2022-09-01  9:32 ` [PATCH liburing v2 08/12] add docs for overflow lost errors Dylan Yudaken
2022-09-01  9:33 ` [PATCH liburing v2 09/12] expose CQ ring overflow state Dylan Yudaken
2022-09-01  9:33 ` [PATCH liburing v2 10/12] overflow: add tests Dylan Yudaken
2022-09-01  9:33 ` [PATCH liburing v2 11/12] file-verify test: log if short read Dylan Yudaken
2022-09-01  9:33 ` Dylan Yudaken [this message]
2022-09-01 11:44   ` [PATCH liburing v2 12/12] shutdown test: bind to ephemeral port Ammar Faizi
2022-09-01 12:54     ` Dylan Yudaken
2022-09-01 13:03       ` Ammar Faizi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox