Make __io_uring_submit_and_wait() do the right thing for flushed ring state
This is a better attempt at fixing what c5bc0ed798e0 was trying to fix.
Use the right state internally, and call __io_uring_submit() even if
we're only waiting for events.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/src/queue.c b/src/queue.c
index 7dec0c0..12abab2 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -193,16 +193,12 @@
static int __io_uring_submit_and_wait(struct io_uring *ring, unsigned wait_nr)
{
- int submitted;
+ int submit;
- submitted = __io_uring_flush_sq(ring);
- if (submitted || io_uring_sq_ready(ring)) {
- if (!submitted)
- submitted = io_uring_sq_ready(ring);
- return __io_uring_submit(ring, submitted, wait_nr);
- }
-
- return 0;
+ submit = __io_uring_flush_sq(ring);
+ if (!submit)
+ submit = *ring->sq.ktail - *ring->sq.khead;
+ return __io_uring_submit(ring, submit, wait_nr);
}
/*