diff options
author | Jens Axboe <axboe@kernel.dk> | 2024-03-18 20:59:18 -0600 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2024-03-18 20:59:18 -0600 |
commit | 27a21b0fe3ce761c3634ff24f32f231a91466bb9 (patch) | |
tree | 0398352ceaf1c82dddd3d0af55b3b7b922d03a21 | |
parent | f11d5b67e8429cfc69ed5bedba30a5bf1956ad3d (diff) | |
download | liburing-27a21b0fe3ce761c3634ff24f32f231a91466bb9.tar.gz |
test/connect: add IOSQE_ASYNC test
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | test/connect.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/test/connect.c b/test/connect.c index a28cb269..5b64545a 100644 --- a/test/connect.c +++ b/test/connect.c @@ -133,7 +133,7 @@ static int configure_connect(int fd, struct sockaddr_in* addr) return ret; } -static int connect_socket(struct io_uring *ring, int fd, int *code) +static int connect_socket(struct io_uring *ring, int fd, int *code, int async) { struct sockaddr_in addr; int ret, res; @@ -150,6 +150,8 @@ static int connect_socket(struct io_uring *ring, int fd, int *code) } io_uring_prep_connect(sqe, fd, (struct sockaddr*)&addr, sizeof(addr)); + if (async) + sqe->flags |= IOSQE_ASYNC; sqe->user_data = 1; ret = submit_and_wait(ring, &res); @@ -186,7 +188,7 @@ static int test_connect_with_no_peer(struct io_uring *ring) if (connect_fd == -1) return -1; - ret = connect_socket(ring, connect_fd, &code); + ret = connect_socket(ring, connect_fd, &code, 0); if (ret == -1) goto err; @@ -209,7 +211,7 @@ err: return -1; } -static int test_connect(struct io_uring *ring) +static int test_connect(struct io_uring *ring, int async) { int accept_fd; int connect_fd; @@ -227,7 +229,7 @@ static int test_connect(struct io_uring *ring) if (connect_fd == -1) goto err1; - ret = connect_socket(ring, connect_fd, &code); + ret = connect_socket(ring, connect_fd, &code, async); if (ret == -1) goto err2; @@ -296,7 +298,7 @@ static int test_connect_timeout(struct io_uring *ring) } // We first connect with one client socket in order to fill the accept queue. - ret = connect_socket(ring, connect_fd[0], &code); + ret = connect_socket(ring, connect_fd[0], &code, 0); if (ret == -1 || code != 0) { fprintf(stderr, "unable to connect\n"); goto err; @@ -390,7 +392,13 @@ int main(int argc, char *argv[]) if (no_connect) return T_EXIT_SKIP; - ret = test_connect(&ring); + ret = test_connect(&ring, 0); + if (ret == -1) { + fprintf(stderr, "test_connect(): failed\n"); + return T_EXIT_FAIL; + } + + ret = test_connect(&ring, 1); if (ret == -1) { fprintf(stderr, "test_connect(): failed\n"); return T_EXIT_FAIL; |