summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2021-03-29 07:58:14 -0600
committerJens Axboe <axboe@kernel.dk>2021-03-29 07:58:14 -0600
commit8bfdf56caaca4dc58e230f07d33f875b7d0648c8 (patch)
treed1f0cbdfcd8b6c31f59afa6009db0b1e8322a3a3
parent13002f787a3744aec62c973e85668ca2ac8d7f24 (diff)
downloadliburing-8bfdf56caaca4dc58e230f07d33f875b7d0648c8.tar.gz
liburing-8bfdf56caaca4dc58e230f07d33f875b7d0648c8.tar.bz2
test/socket-rw*: don't fatally error on failure to bind
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--test/socket-rw-eagain.c14
-rw-r--r--test/socket-rw.c13
2 files changed, 21 insertions, 6 deletions
diff --git a/test/socket-rw-eagain.c b/test/socket-rw-eagain.c
index b6406d8..f15c0c1 100644
--- a/test/socket-rw-eagain.c
+++ b/test/socket-rw-eagain.c
@@ -38,11 +38,19 @@ int main(int argc, char *argv[])
assert(ret != -1);
addr.sin_family = AF_INET;
- addr.sin_port = (rand() % 61440) + 4096;
addr.sin_addr.s_addr = 0x0100007fU;
- ret = bind(recv_s0, (struct sockaddr*)&addr, sizeof(addr));
- assert(ret != -1);
+ do {
+ addr.sin_port = (rand() % 61440) + 4096;
+ ret = bind(recv_s0, (struct sockaddr*)&addr, sizeof(addr));
+ if (!ret)
+ break;
+ if (errno != EADDRINUSE) {
+ perror("bind");
+ exit(1);
+ }
+ } while (1);
+
ret = listen(recv_s0, 128);
assert(ret != -1);
diff --git a/test/socket-rw.c b/test/socket-rw.c
index 47ae25c..1b731b2 100644
--- a/test/socket-rw.c
+++ b/test/socket-rw.c
@@ -40,11 +40,18 @@ int main(int argc, char *argv[])
assert(ret != -1);
addr.sin_family = AF_INET;
- addr.sin_port = (rand() % 61440) + 4096;
addr.sin_addr.s_addr = 0x0100007fU;
- ret = bind(recv_s0, (struct sockaddr*)&addr, sizeof(addr));
- assert(ret != -1);
+ do {
+ addr.sin_port = (rand() % 61440) + 4096;
+ ret = bind(recv_s0, (struct sockaddr*)&addr, sizeof(addr));
+ if (!ret)
+ break;
+ if (errno != EADDRINUSE) {
+ perror("bind");
+ exit(1);
+ }
+ } while (1);
ret = listen(recv_s0, 128);
assert(ret != -1);