summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2019-11-22 22:28:47 -0700
committerJens Axboe <axboe@kernel.dk>2019-11-22 22:28:47 -0700
commit566506fa226077a51b313d964fdad5ad2836a3f0 (patch)
tree11c08254c85c87b272a9c1317bd7e17cebba3f25
parent514acf956ee80594481402e3c8470f8eec5d3b89 (diff)
downloadliburing-566506fa226077a51b313d964fdad5ad2836a3f0.tar.gz
liburing-566506fa226077a51b313d964fdad5ad2836a3f0.tar.bz2
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>
-rw-r--r--src/queue.c14
1 files changed, 5 insertions, 9 deletions
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(struct io_uring *ring, unsigned submitted,
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);
}
/*