diff options
author | Donald Hunter <donald.hunter@gmail.com> | 2022-06-17 22:36:01 +0800 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2022-06-17 08:41:45 -0600 |
commit | c8909b9e1963f4651927f8f46d1d0420d28bcd58 (patch) | |
tree | 9f035016990dc83dcf07c28bcb374dab47c7308d | |
parent | 540ca1c11016ed50940e3f6f555a986356578646 (diff) | |
download | liburing-c8909b9e1963f4651927f8f46d1d0420d28bcd58.tar.gz |
Fix incorrect close in test for multishot accept
This fixes a bug in accept_conn handling in the accept tests that caused it
to incorrectly skip the multishot tests and also lose the warning message
to a closed stdout. This can be seen in the strace output below.
close(1) = 0
io_uring_setup(32, { ...
...
write(1, "Fixed Multishot Accept not suppo"..., 47) = -1 EINVAL
Unfortunately this exposes a a bug with gcc -O2 where multishot_mask logic
gets optimized incorrectly and "Fixed Multishot Accept misses events" is
wrongly reported. I am investigating this separately.
Fixes: 66cf84527c34 ("test/accept.c: add test for multishot mode accept")
Signed-off-by: Donald Hunter <donald.hunter@gmail.com>
Link: https://lore.kernel.org/r/20220617143603.179277-2-hao.xu@linux.dev
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | test/accept.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/test/accept.c b/test/accept.c index 7bc6226..fb87a1d 100644 --- a/test/accept.c +++ b/test/accept.c @@ -103,7 +103,7 @@ static void queue_accept_conn(struct io_uring *ring, int fd, } } -static int accept_conn(struct io_uring *ring, int fixed_idx) +static int accept_conn(struct io_uring *ring, int fixed_idx, bool multishot) { struct io_uring_cqe *cqe; int ret; @@ -115,8 +115,10 @@ static int accept_conn(struct io_uring *ring, int fixed_idx) if (fixed_idx >= 0) { if (ret > 0) { - close(ret); - return -EINVAL; + if (!multishot) { + close(ret); + return -EINVAL; + } } else if (!ret) { ret = fixed_idx; } @@ -208,7 +210,7 @@ static int test_loop(struct io_uring *ring, queue_accept_conn(ring, recv_s0, args); for (i = 0; i < MAX_FDS; i++) { - s_fd[i] = accept_conn(ring, args.fixed ? 0 : -1); + s_fd[i] = accept_conn(ring, args.fixed ? 0 : -1, multishot); if (s_fd[i] == -EINVAL) { if (args.accept_should_error) goto out; |