Skip to content

Commit 7c4ddb5

Browse files
committed
input/uring: initialize uring_input_queue lazily
The BlockingCall() in InitUringInputPlugin() did not work because the EventThread was not yet started. This was never noticed until commit e309941 which enabled `IORING_SETUP_SINGLE_ISSUER`, and suddenly the kernel refused to accept io_uring_submit() calls from the io_thread because io_uring_setup() had been called from the main thread.
1 parent 3cf5354 commit 7c4ddb5

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/input/plugins/UringInputPlugin.cxx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ static const size_t URING_RESUME_AT = 384 * 1024;
3333

3434
static EventLoop *uring_input_event_loop;
3535
static Uring::Queue *uring_input_queue;
36+
static bool uring_input_initialized = false;
3637

3738
class UringInputStream final : public AsyncInputStream, Uring::ReadHandler {
3839
Uring::Queue ů
@@ -163,6 +164,16 @@ UringInputStream::OnReadError(int error) noexcept
163164
InputStreamPtr
164165
OpenUringInputStream(const char *path, Mutex &mutex)
165166
{
167+
if (!uring_input_initialized) {
168+
BlockingCall(*uring_input_event_loop, [](){
169+
if (uring_input_initialized)
170+
return;
171+
172+
uring_input_queue = uring_input_event_loop->GetUring();
173+
uring_input_initialized = true;
174+
});
175+
}
176+
166177
if (uring_input_queue == nullptr)
167178
return nullptr;
168179

@@ -187,8 +198,4 @@ void
187198
InitUringInputPlugin(EventLoop &event_loop) noexcept
188199
{
189200
uring_input_event_loop = &event_loop;
190-
191-
BlockingCall(event_loop, [](){
192-
uring_input_queue = uring_input_event_loop->GetUring();
193-
});
194201
}

0 commit comments

Comments
 (0)