diff options
author | Jens Axboe <axboe@kernel.dk> | 2024-04-20 16:48:03 -0600 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2024-04-20 16:48:03 -0600 |
commit | 3331290311608f6c671278dd00e4d54934117f38 (patch) | |
tree | 34bdfcbc5040721053e3f464cb6003f3139564c8 | |
parent | c18c8fbcdfbd4ab785cf75bf22a0f9498cedd077 (diff) | |
download | liburing-3331290311608f6c671278dd00e4d54934117f38.tar.gz |
test/msg-ring: synchronize remote test case with a pthread barrier
Link: https://github.com/axboe/liburing/issues/1135
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | test/msg-ring.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/test/msg-ring.c b/test/msg-ring.c index bc8cdb5d..9d5d10a3 100644 --- a/test/msg-ring.c +++ b/test/msg-ring.c @@ -72,12 +72,20 @@ err: return 1; } -static void *wait_cqe_fn(void *data) +struct data { + struct io_uring *ring; + pthread_barrier_t barrier; +}; + +static void *wait_cqe_fn(void *__data) { - struct io_uring *ring = data; + struct data *d = __data; + struct io_uring *ring = d->ring; struct io_uring_cqe *cqe; int ret; + pthread_barrier_wait(&d->barrier); + ret = io_uring_wait_cqe(ring, &cqe); if (ret) { fprintf(stderr, "wait cqe %d\n", ret); @@ -106,9 +114,12 @@ static int test_remote(struct io_uring *ring, struct io_uring *target) void *tret; struct io_uring_cqe *cqe; struct io_uring_sqe *sqe; + struct data d; int ret; - pthread_create(&thread, NULL, wait_cqe_fn, target); + d.ring = target; + pthread_barrier_init(&d.barrier, NULL, 2); + pthread_create(&thread, NULL, wait_cqe_fn, &d); sqe = io_uring_get_sqe(ring); if (!sqe) { @@ -125,6 +136,8 @@ static int test_remote(struct io_uring *ring, struct io_uring *target) goto err; } + pthread_barrier_wait(&d.barrier); + ret = io_uring_wait_cqe(ring, &cqe); if (ret < 0) { fprintf(stderr, "wait completion %d\n", ret); |