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

Function test_single_timeout_wait

test/timeout.c:180–233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

178}
179
180static int test_single_timeout_wait(struct io_uring *ring,
181 struct io_uring_params *p)
182{
183 struct io_uring_cqe *cqe;
184 struct io_uring_sqe *sqe;
185 struct __kernel_timespec ts;
186 int i, ret;
187
188 sqe = io_uring_get_sqe(ring);
189 io_uring_prep_nop(sqe);
190 io_uring_sqe_set_data(sqe, (void *) 1);
191
192 sqe = io_uring_get_sqe(ring);
193 io_uring_prep_nop(sqe);
194 io_uring_sqe_set_data(sqe, (void *) 1);
195
196 /* no implied submit for newer kernels */
197 if (p->features & IORING_FEAT_EXT_ARG) {
198 ret = io_uring_submit(ring);
199 if (ret != 2) {
200 fprintf(stderr, "%s: submit %d\n", __FUNCTION__, ret);
201 return 1;
202 }
203 }
204
205 msec_to_ts(&ts, 1000);
206
207 i = 0;
208 do {
209 ret = io_uring_wait_cqes(ring, &cqe, 2, &ts, NULL);
210 if (ret == -ETIME)
211 break;
212 if (ret < 0) {
213 fprintf(stderr, "%s: wait timeout failed: %d\n", __FUNCTION__, ret);
214 goto err;
215 }
216
217 ret = cqe->res;
218 io_uring_cqe_seen(ring, cqe);
219 if (ret < 0) {
220 fprintf(stderr, "res: %d\n", ret);
221 goto err;
222 }
223 i++;
224 } while (1);
225
226 if (i != 2) {
227 fprintf(stderr, "got %d completions\n", i);
228 goto err;
229 }
230 return 0;
231err:
232 return 1;
233}
234
235/*
236 * Test single timeout waking us up

Callers 1

mainFunction · 0.85

Calls 4

io_uring_submitFunction · 0.85
io_uring_wait_cqesFunction · 0.85
msec_to_tsFunction · 0.70
io_uring_get_sqeFunction · 0.50

Tested by

no test coverage detected