summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2019-09-27 05:35:28 -0600
committerJens Axboe <axboe@kernel.dk>2019-09-27 06:10:13 -0600
commit94c9df3b934cdfbc36ce1f795b537c7d47689407 (patch)
tree2265ab25ed1e278c62309d20bbe727d9370f2f42 /src
parent8578f0d9fcefb2b04150f50a008fd19725ea6006 (diff)
downloadliburing-94c9df3b934cdfbc36ce1f795b537c7d47689407.tar.gz
liburing-94c9df3b934cdfbc36ce1f795b537c7d47689407.tar.bz2
Add __io_uring_submit_and_wait() helper
Used in two spots, instead of open coding it. Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'src')
-rw-r--r--src/queue.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/queue.c b/src/queue.c
index bdbc2b8..f8a6ce7 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -219,36 +219,35 @@ static int __io_uring_submit(struct io_uring *ring, unsigned submitted,
return ret;
}
-/*
- * Submit sqes acquired from io_uring_get_sqe() to the kernel.
- *
- * Returns number of sqes submitted
- */
-int io_uring_submit(struct io_uring *ring)
+static int __io_uring_submit_and_wait(struct io_uring *ring, unsigned wait_nr)
{
int submitted;
submitted = __io_uring_flush_sq(ring);
if (submitted)
- return __io_uring_submit(ring, submitted, 0);
+ return __io_uring_submit(ring, submitted, wait_nr);
return 0;
}
/*
+ * Submit sqes acquired from io_uring_get_sqe() to the kernel.
+ *
+ * Returns number of sqes submitted
+ */
+int io_uring_submit(struct io_uring *ring)
+{
+ return __io_uring_submit_and_wait(ring, 0);
+}
+
+/*
* Like io_uring_submit(), but allows waiting for events as well.
*
* Returns number of sqes submitted
*/
int io_uring_submit_and_wait(struct io_uring *ring, unsigned wait_nr)
{
- int submitted;
-
- submitted = __io_uring_flush_sq(ring);
- if (submitted)
- return __io_uring_submit(ring, submitted, wait_nr);
-
- return 0;
+ return __io_uring_submit_and_wait(ring, wait_nr);
}
/*