io/uring/Queue: add method RequireSubmitEntry()
Fixes assertion failure when the submit queue is empty.
This commit is contained in:

committed by
Max Kellermann

parent
c8f174ac92
commit
799032505e
@@ -34,6 +34,8 @@
|
||||
#include "CancellableOperation.hxx"
|
||||
#include "util/DeleteDisposer.hxx"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
namespace Uring {
|
||||
|
||||
Queue::Queue(unsigned entries, unsigned flags)
|
||||
@@ -46,6 +48,23 @@ Queue::~Queue() noexcept
|
||||
operations.clear_and_dispose(DeleteDisposer{});
|
||||
}
|
||||
|
||||
struct io_uring_sqe &
|
||||
Queue::RequireSubmitEntry()
|
||||
{
|
||||
auto *sqe = GetSubmitEntry();
|
||||
if (sqe == nullptr) {
|
||||
/* the submit queue is full; submit it to the kernel
|
||||
and try again */
|
||||
Submit();
|
||||
|
||||
sqe = GetSubmitEntry();
|
||||
if (sqe == nullptr)
|
||||
throw std::runtime_error{"io_uring_get_sqe() failed"};
|
||||
}
|
||||
|
||||
return *sqe;
|
||||
}
|
||||
|
||||
void
|
||||
Queue::AddPending(struct io_uring_sqe &sqe,
|
||||
Operation &operation) noexcept
|
||||
|
Reference in New Issue
Block a user