diff options
author | thegeorg <thegeorg@yandex-team.com> | 2024-06-09 11:55:21 +0300 |
---|---|---|
committer | thegeorg <thegeorg@yandex-team.com> | 2024-06-09 12:07:55 +0300 |
commit | afd4899380eea1c70e2a68714b5da1c9919ccdbd (patch) | |
tree | cd5120708784139bc6a0f8881da1ed8389a065b3 /contrib/libs/liburing/test/connect.c | |
parent | a83bd2dd3c21e38c6c0807ec5e679497ab567f24 (diff) | |
download | ydb-afd4899380eea1c70e2a68714b5da1c9919ccdbd.tar.gz |
Update contrib/libs/liburing to 2.6
3b51a9fb14de805208d11f1c077c78bb5d487e0f
Diffstat (limited to 'contrib/libs/liburing/test/connect.c')
-rw-r--r-- | contrib/libs/liburing/test/connect.c | 57 |
1 files changed, 46 insertions, 11 deletions
diff --git a/contrib/libs/liburing/test/connect.c b/contrib/libs/liburing/test/connect.c index f1b7d941f4..cabf3599eb 100644 --- a/contrib/libs/liburing/test/connect.c +++ b/contrib/libs/liburing/test/connect.c @@ -134,7 +134,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; @@ -151,6 +151,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); @@ -187,7 +189,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; @@ -210,7 +212,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; @@ -228,7 +230,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; @@ -297,7 +299,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; @@ -364,15 +366,12 @@ err: return -1; } -int main(int argc, char *argv[]) +static int test(int flags) { struct io_uring ring; int ret; - if (argc > 1) - return T_EXIT_SKIP; - - ret = io_uring_queue_init(8, &ring, 0); + ret = io_uring_queue_init(8, &ring, flags); if (ret) { fprintf(stderr, "io_uring_queue_setup() = %d\n", ret); return T_EXIT_FAIL; @@ -391,7 +390,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; @@ -406,3 +411,33 @@ int main(int argc, char *argv[]) io_uring_queue_exit(&ring); return T_EXIT_PASS; } + +int main(int argc, char *argv[]) +{ + int ret; + + if (argc > 1) + return T_EXIT_SKIP; + + ret = test(0); + if (ret == -1) { + fprintf(stderr, "test 0 failed\n"); + return T_EXIT_FAIL; + } + if (no_connect) + return T_EXIT_SKIP; + + ret = test(IORING_SETUP_SQPOLL); + if (ret == -1) { + fprintf(stderr, "test SQPOLL failed\n"); + return T_EXIT_FAIL; + } + + ret = test(IORING_SETUP_SINGLE_ISSUER|IORING_SETUP_DEFER_TASKRUN); + if (ret == -1) { + fprintf(stderr, "test DEFER failed\n"); + return T_EXIT_FAIL; + } + + return T_EXIT_PASS; +} |