summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2020-05-15 10:50:04 -0600
committerJens Axboe <axboe@kernel.dk>2020-05-15 10:50:04 -0600
commit2a6c26c2200d5b129e22276d099a72d78d6deeed (patch)
tree8521dafa9c75bbdfd250935a6bb47e00265cbb84 /test
parentfe500488190ff39716346ee1c0fe66bde300d0fb (diff)
downloadliburing-2a6c26c2200d5b129e22276d099a72d78d6deeed.tar.gz
liburing-2a6c26c2200d5b129e22276d099a72d78d6deeed.tar.bz2
test/open-close: fix race with closing ring itself
Depending on timing, we can get -EBADF from the waiting on a completion. This is fine, as we've closed the ring itself, so we cannot rely the completion coming in, it'll depend completely on the timing of events. Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'test')
-rw-r--r--test/open-close.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/test/open-close.c b/test/open-close.c
index ee564a7..cb74d91 100644
--- a/test/open-close.c
+++ b/test/open-close.c
@@ -31,7 +31,7 @@ static int create_file(const char *file, size_t size)
return ret != size;
}
-static int test_close(struct io_uring *ring, int fd)
+static int test_close(struct io_uring *ring, int fd, int is_ring_fd)
{
struct io_uring_cqe *cqe;
struct io_uring_sqe *sqe;
@@ -52,8 +52,11 @@ static int test_close(struct io_uring *ring, int fd)
ret = io_uring_wait_cqe(ring, &cqe);
if (ret < 0) {
- fprintf(stderr, "wait completion %d\n", ret);
- goto err;
+ if (!(is_ring_fd && ret == -EBADF)) {
+ fprintf(stderr, "wait completion %d\n", ret);
+ goto err;
+ }
+ return ret;
}
ret = cqe->res;
io_uring_cqe_seen(ring, cqe);
@@ -140,13 +143,13 @@ int main(int argc, char *argv[])
goto err;
}
- ret = test_close(&ring, ret);
+ ret = test_close(&ring, ret, 0);
if (ret) {
fprintf(stderr, "test_close normal failed\n");
goto err;
}
- ret = test_close(&ring, ring.ring_fd);
+ ret = test_close(&ring, ring.ring_fd, 1);
if (ret != -EBADF) {
fprintf(stderr, "test_close ring_fd failed\n");
goto err;