io/uring/Queue: dispatch all completions in SubmitAndWaitDispatchOneCompletion()

io_uring_submit_and_wait_timeout() can return multiple completions,
even if we wait for only one.  We should dispatch them all or we miss
wakeups.
This commit is contained in:
Max Kellermann
2025-02-04 19:57:35 +01:00
committed by Max Kellermann
parent 2276ebd70f
commit bca9e3e347
2 changed files with 3 additions and 4 deletions
src/io/uring

@ -104,14 +104,13 @@ Queue::WaitDispatchOneCompletion()
} }
bool bool
Queue::SubmitAndWaitDispatchOneCompletion(struct __kernel_timespec &timeout) Queue::SubmitAndWaitDispatchCompletions(struct __kernel_timespec &timeout)
{ {
auto *cqe = ring.SubmitAndWaitCompletion(timeout); auto *cqe = ring.SubmitAndWaitCompletion(timeout);
if (cqe == nullptr) if (cqe == nullptr)
return false; return false;
DispatchOneCompletion(*cqe); return DispatchCompletions(*cqe) > 0;
return true;
} }
} // namespace Uring } // namespace Uring

@ -101,7 +101,7 @@ public:
while (WaitDispatchOneCompletion()) {} while (WaitDispatchOneCompletion()) {}
} }
bool SubmitAndWaitDispatchOneCompletion(struct __kernel_timespec &timeout); bool SubmitAndWaitDispatchCompletions(struct __kernel_timespec &timeout);
private: private:
static void _DispatchOneCompletion(const struct io_uring_cqe &cqe) noexcept; static void _DispatchOneCompletion(const struct io_uring_cqe &cqe) noexcept;