Skip to content

Commit

Permalink
io/uring/Queue: dispatch all completions in SubmitAndWaitDispatchOneC…
Browse files Browse the repository at this point in the history
…ompletion()

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.
  • Loading branch information
MaxKellermann committed Feb 13, 2025
1 parent 2276ebd commit bca9e3e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/io/uring/Queue.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,13 @@ Queue::WaitDispatchOneCompletion()
}

bool
Queue::SubmitAndWaitDispatchOneCompletion(struct __kernel_timespec &timeout)
Queue::SubmitAndWaitDispatchCompletions(struct __kernel_timespec &timeout)
{
auto *cqe = ring.SubmitAndWaitCompletion(timeout);
if (cqe == nullptr)
return false;

DispatchOneCompletion(*cqe);
return true;
return DispatchCompletions(*cqe) > 0;
}

} // namespace Uring
2 changes: 1 addition & 1 deletion src/io/uring/Queue.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public:
while (WaitDispatchOneCompletion()) {}
}

bool SubmitAndWaitDispatchOneCompletion(struct __kernel_timespec &timeout);
bool SubmitAndWaitDispatchCompletions(struct __kernel_timespec &timeout);

private:
static void _DispatchOneCompletion(const struct io_uring_cqe &cqe) noexcept;
Expand Down

0 comments on commit bca9e3e

Please sign in to comment.