MCPcopy Create free account
hub / github.com/axboe/liburing / thread_func

Function thread_func

test/exit-no-cleanup.c:34–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32static sem_t sem;
33
34static void *thread_func(void *arg)
35{
36 struct io_uring ring;
37 int res;
38
39 res = io_uring_queue_init(IORING_ENTRIES, &ring, 0);
40 if (res)
41 err(EXIT_FAILURE, "io_uring_queue_init failed");
42
43 pthread_barrier_wait(&init_barrier);
44
45 for(;;) {
46 struct io_uring_cqe *cqe;
47 struct io_uring_sqe *sqe;
48 uint64_t buf;
49 int res;
50
51 sqe = io_uring_get_sqe(&ring);
52 assert(sqe);
53
54 io_uring_prep_read(sqe, sleep_fd, &buf, sizeof(buf), 0);
55
56 res = io_uring_submit_and_wait(&ring, 1);
57 if (res < 0)
58 err(EXIT_FAILURE, "io_uring_submit_and_wait failed");
59
60 res = io_uring_peek_cqe(&ring, &cqe);
61 assert(!res);
62 if (cqe->res < 0) {
63 errno = -cqe->res;
64 err(EXIT_FAILURE, "read failed");
65 }
66 assert(cqe->res == sizeof(buf));
67
68 sem_post(&sem);
69
70 io_uring_cqe_seen(&ring, cqe);
71 }
72
73 return NULL;
74}
75
76int main(int argc, char *argv[])
77{

Callers

nothing calls this directly

Calls 3

io_uring_queue_initFunction · 0.85
io_uring_submit_and_waitFunction · 0.85
io_uring_get_sqeFunction · 0.50

Tested by

no test coverage detected