io_uring_wait_cqes(3)
π io_uring_wait_cqes β bestie edition π
okay so this is a page from the liburing manual, and it's all about io_uring_wait_cqes(3). yes the name is a mouthful, we love her anyway π«Ά
β¨ NAME β¨
io_uring_wait_cqes β literally just hanging out until one or more io_uring completion events show up π
πΈ SYNOPSIS πΈ
#include <liburing.h>
int io_uring_wait_cqes(struct io_uring *ring,
struct io_uring_cqe **cqe_ptr,
unsigned wait_nr,
struct __kernel_timespec *ts,
sigset_t *sigmask);
π¦ DESCRIPTION π¦
so io_uring_wait_cqes(3) grabs you wait_nr IO completions from the queue that belongs to the ring param. and if they're not there yet? she waits for them. or she waits until the timeout ts expires, whichever comes first. no cap π
the sigmask tells her which signals to block. if you set it, it's equivalent to atomically running these calls:
sigset_t origmask;
pthread_sigmask(SIG_SETMASK, &sigmask, &origmask);
ret = io_uring_wait_cqes(ring, cqe, wait_nr, ts, NULL);
pthread_sigmask(SIG_SETMASK, &origmask, NULL);
the cqe_ptr param gets filled in on success with the first CQE. and bestie, if you're calling this, you should use io_uring_for_each_cqe(3) to iterate through all the available CQEs, not just the first one. okay? okay π
now, if ts is specified and you're on an older kernel without IORING_FEAT_EXT_ARG, your app does not need to call io_uring_submit(3) before calling io_uring_wait_cqes(3). cute. but for newer kernels with that feature flag set, there is no implied submit when waiting for a request. so don't be out here assuming, bestie, check your kernel π
and if ts is NULL, then this just behaves like io_uring_wait_cqe(3) β meaning she will wait forever for an event. forever forever. iconic but also π
β RETURN VALUE β
- on success,
io_uring_wait_cqes(3)returns0, and thecqe_ptrparam gets filled in. slay π - on failure, it returns
-errno. classic. - and if a timeout occurs, it returns
-ETIME. so if you see that one, that's the clock, not a bug π
π SEE ALSO π
and that's the whole page, bestie. this was liburing-2.1, dated November 15, 2021 β so go forth, wait on your completions, and remember: ts is NULL means forever, and forever is a long time π¦πβ¨
π¦ where this page comes from
- alpine 3.23: liburing-doc 2.12-r0 Β· LGPL-2.1-or-later OR MIT
- alpine 3.24: liburing-doc 2.14-r0 Β· LGPL-2.1-or-later OR MIT
- arch rolling: liburing 2.15-1 Β· GPL-2.0-only WITH Linux-syscall-note OR MIT AND LGPL-2.0-or-later AND MIT
- centos-stream 10: liburing-devel 2.12-1.el10 Β· (GPLv2 with exceptions and LGPLv2+) or MIT
- centos-stream 9: liburing-devel 2.12-1.el9 Β· (GPLv2 with exceptions and LGPLv2+) or MIT
- centos-stream 9: liburing-devel 2.12-1.el9 Β· (GPLv2 with exceptions and LGPLv2+) or MIT
- fedora 44: liburing-devel 2.13-2.fc44 Β· (GPL-2.0-only WITH Linux-syscall-note OR MIT) AND (LGPL-2.0-or-later OR MIT)
- fedora 44: liburing-devel 2.13-2.fc44 Β· (GPL-2.0-only WITH Linux-syscall-note OR MIT) AND (LGPL-2.0-or-later OR MIT)
- nixpkgs unstable: liburing 2.14
- ubuntu resolute: liburing-dev 2.14-1
- ubuntu stonking: liburing-dev 2.15-1
- π the page's license: LGPL-2.0-or-later
- Copyright (C) 2021 Stefan Roesch <shr@fb.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms