summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2019-10-18 11:12:26 -0600
committerJens Axboe <axboe@kernel.dk>2019-10-18 11:12:26 -0600
commit6b998558791ae8fab37967d44e8da39d6921d0a8 (patch)
tree45f1d0a7a13c93026d38b40d9a8a0372234afd80
parenta9bb08db3f8795eb58239d5dbb888e9c1d424011 (diff)
downloadliburing-6b998558791ae8fab37967d44e8da39d6921d0a8.tar.gz
liburing-6b998558791ae8fab37967d44e8da39d6921d0a8.tar.bz2
test/accept: fix a few errors
- Don't re-init the io_uring - SQPOLL can fail with -EBADF or -EINVAL, depends on which path the sqe takes. Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--test/accept.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/test/accept.c b/test/accept.c
index 6935b99..64cdbaf 100644
--- a/test/accept.c
+++ b/test/accept.c
@@ -62,7 +62,7 @@ static int accept_conn(struct io_uring *ring, int fd)
return ret;
}
-static int test(struct io_uring *ring, int accept_should_einval)
+static int test(struct io_uring *ring, int accept_should_error)
{
struct io_uring_cqe *cqe;
uint32_t head;
@@ -104,17 +104,20 @@ static int test(struct io_uring *ring, int accept_should_einval)
flags &= ~O_NONBLOCK;
assert(fcntl(p_fd[1], F_SETFL, flags) != -1);
- assert(io_uring_queue_init(32, ring, 0) >= 0);
-
p_fd[0] = accept_conn(ring, recv_s0);
if (p_fd[0] == -EINVAL) {
- if (accept_should_einval)
+ if (accept_should_error)
goto out;
fprintf(stdout, "Accept not supported, skipping\n");
no_accept = 1;
goto out;
+ } else if (p_fd[0] < 0) {
+ if (accept_should_error &&
+ (p_fd[0] == -EBADF || p_fd[0] == -EINVAL))
+ goto out;
+ fprintf(stderr, "Accept got %d\n", p_fd[0]);
+ goto err;
}
- assert(p_fd[0] >= 0);
queue_send(ring, p_fd[1]);
queue_recv(ring, p_fd[0]);