summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2019-09-27 07:26:45 -0600
committerJens Axboe <axboe@kernel.dk>2019-09-27 08:32:50 -0600
commitac72640594bcb04b4952e7b2b83b06f2046afa8a (patch)
tree75268c17aef3179ed7e036d4b5f9df371fce1252 /src
parent1409c4a4d81e3a86fecbc42889541e866fc30abe (diff)
downloadliburing-ac72640594bcb04b4952e7b2b83b06f2046afa8a.tar.gz
liburing-ac72640594bcb04b4952e7b2b83b06f2046afa8a.tar.bz2
Fold io_uring_wait_cqes_timeout() with io_uring_wait_cqes()
We also need the sigset for certain setups, and adding a third option is pretty crazy. Since io_uring_wait_cqes_timeout() isn't in a released version yet (and neither is io_uring_wait_cqes()), make the necessary adjustments. Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'src')
-rw-r--r--src/include/liburing.h5
-rw-r--r--src/liburing.map1
-rw-r--r--src/queue.c35
3 files changed, 11 insertions, 30 deletions
diff --git a/src/include/liburing.h b/src/include/liburing.h
index 74b83f0..f5c27d8 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -77,9 +77,8 @@ unsigned io_uring_peek_batch_cqe(struct io_uring *ring,
extern int io_uring_wait_cqe(struct io_uring *ring,
struct io_uring_cqe **cqe_ptr);
extern int io_uring_wait_cqes(struct io_uring *ring,
- struct io_uring_cqe **cqe_ptr, unsigned wait_nr);
-extern int io_uring_wait_cqes_timeout(struct io_uring *ring,
- struct io_uring_cqe **cqe_ptr, unsigned wait_nr, struct timespec *ts);
+ struct io_uring_cqe **cqe_ptr, unsigned wait_nr, struct timespec *ts,
+ sigset_t *sigmask);
extern int io_uring_wait_cqe_timeout(struct io_uring *ring,
struct io_uring_cqe **cqe_ptr, struct timespec *ts);
extern int io_uring_submit(struct io_uring *ring);
diff --git a/src/liburing.map b/src/liburing.map
index 18b816c..969ec61 100644
--- a/src/liburing.map
+++ b/src/liburing.map
@@ -27,6 +27,5 @@ LIBURING_0.2 {
global:
io_uring_peek_batch_cqe;
io_uring_wait_cqe_timeout;
- io_uring_wait_cqes_timeout;
io_uring_wait_cqes;
} LIBURING_0.1;
diff --git a/src/queue.c b/src/queue.c
index 1493d38..b9e26a0 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -13,7 +13,7 @@
static int __io_uring_get_cqe(struct io_uring *ring,
struct io_uring_cqe **cqe_ptr, unsigned submit,
- unsigned wait_nr)
+ unsigned wait_nr, sigset_t *sigmask)
{
int ret, err = 0;
unsigned head;
@@ -35,7 +35,7 @@ static int __io_uring_get_cqe(struct io_uring *ring,
if (!wait_nr)
return -EAGAIN;
ret = io_uring_enter(ring->ring_fd, submit, wait_nr,
- IORING_ENTER_GETEVENTS, NULL);
+ IORING_ENTER_GETEVENTS, sigmask);
if (ret < 0)
return -errno;
} while (1);
@@ -49,7 +49,7 @@ static int __io_uring_get_cqe(struct io_uring *ring,
*/
int io_uring_peek_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr)
{
- return __io_uring_get_cqe(ring, cqe_ptr, 0, 0);
+ return __io_uring_get_cqe(ring, cqe_ptr, 0, 0, NULL);
}
/*
@@ -120,17 +120,7 @@ static int __io_uring_flush_sq(struct io_uring *ring)
*/
int io_uring_wait_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr)
{
- return __io_uring_get_cqe(ring, cqe_ptr, 0, 1);
-}
-
-/*
- * Like io_uring_wait_cqe(), except we ask to wait for more entries in the
- * kernel.
- */
-int io_uring_wait_cqes(struct io_uring *ring, struct io_uring_cqe **cqe_ptr,
- unsigned wait_nr)
-{
- return __io_uring_get_cqe(ring, cqe_ptr, 0, wait_nr);
+ return __io_uring_get_cqe(ring, cqe_ptr, 0, 1, NULL);
}
/*
@@ -141,17 +131,12 @@ int io_uring_wait_cqes(struct io_uring *ring, struct io_uring_cqe **cqe_ptr,
* Note that the application need not call io_uring_submit() before calling
* this function, as we will do that on its behalf.
*/
-int io_uring_wait_cqes_timeout(struct io_uring *ring,
- struct io_uring_cqe **cqe_ptr,
- unsigned wait_nr,
- struct timespec *ts)
+int io_uring_wait_cqes(struct io_uring *ring, struct io_uring_cqe **cqe_ptr,
+ unsigned wait_nr, struct timespec *ts, sigset_t *sigmask)
{
int ret;
- if (!ts)
- return io_uring_wait_cqes(ring, cqe_ptr, wait_nr);
-
- if (wait_nr) {
+ if (wait_nr && ts) {
struct io_uring_sqe *sqe;
/*
@@ -169,10 +154,8 @@ int io_uring_wait_cqes_timeout(struct io_uring *ring,
}
ret = __io_uring_flush_sq(ring);
- if (!ret)
- return ret;
- return __io_uring_get_cqe(ring, cqe_ptr, ret, wait_nr);
+ return __io_uring_get_cqe(ring, cqe_ptr, ret, wait_nr, sigmask);
}
/*
@@ -183,7 +166,7 @@ int io_uring_wait_cqe_timeout(struct io_uring *ring,
struct io_uring_cqe **cqe_ptr,
struct timespec *ts)
{
- return io_uring_wait_cqes_timeout(ring, cqe_ptr, 1, ts);
+ return io_uring_wait_cqes(ring, cqe_ptr, 1, ts, NULL);
}
/*