mirror of
https://github.com/decompals/wibo.git
synced 2025-12-16 16:37:12 +00:00
Gracefully fallback when io_uring fails to initialize
This commit is contained in:
@@ -6,7 +6,7 @@ namespace {
|
|||||||
|
|
||||||
std::unique_ptr<wibo::AsyncIOBackend> g_backend;
|
std::unique_ptr<wibo::AsyncIOBackend> g_backend;
|
||||||
|
|
||||||
class DummyBackend : public wibo::AsyncIOBackend {
|
class NoOpBackend : public wibo::AsyncIOBackend {
|
||||||
public:
|
public:
|
||||||
bool init() override { return true; }
|
bool init() override { return true; }
|
||||||
void shutdown() override {}
|
void shutdown() override {}
|
||||||
@@ -43,12 +43,12 @@ AsyncIOBackend &asyncIO() {
|
|||||||
#if WIBO_ENABLE_LIBURING
|
#if WIBO_ENABLE_LIBURING
|
||||||
g_backend = detail::createIoUringBackend();
|
g_backend = detail::createIoUringBackend();
|
||||||
#else
|
#else
|
||||||
g_backend = std::make_unique<DummyBackend>();
|
g_backend = std::make_unique<NoOpBackend>();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (!g_backend->init()) {
|
if (!g_backend->init()) {
|
||||||
fprintf(stderr, "asyncIO: failed to initialize backend\n");
|
DEBUG_LOG("AsyncIOBackend initialization failed; using no-op backend\n");
|
||||||
abort();
|
g_backend = std::make_unique<NoOpBackend>();
|
||||||
}
|
}
|
||||||
return *g_backend;
|
return *g_backend;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user