From 24dd7610bc886cfd6b387f0c60cc03c8e961c628 Mon Sep 17 00:00:00 2001 From: xiehan <52160700+Barenboim@users.noreply.github.com> Date: Wed, 15 Jan 2025 20:51:32 +0800 Subject: [PATCH] Decrease max aio events when io_setup() failed. (#1689) --- src/manager/WFGlobal.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/manager/WFGlobal.cc b/src/manager/WFGlobal.cc index dc006edf67f..6f2934a7b9c 100644 --- a/src/manager/WFGlobal.cc +++ b/src/manager/WFGlobal.cc @@ -397,10 +397,19 @@ inline IOService *__CommManager::get_io_service() if (!fio_flag_) { int maxevents = WFGlobal::get_global_settings()->fio_max_events; + int n = 65536; fio_service_ = new __FileIOService(&scheduler_); - if (fio_service_->init(maxevents) < 0) - abort(); + while (fio_service_->init(maxevents) < 0) + { + if ((errno != EAGAIN && errno != EINVAL) || maxevents <= 16) + abort(); + + while (n >= maxevents) + n /= 2; + + maxevents = n; + } if (fio_service_->bind() < 0) abort();