diff --git a/lib/methods/ifwapichecktask.cpp b/lib/methods/ifwapichecktask.cpp index 62096ee9a1d..76f8845b755 100644 --- a/lib/methods/ifwapichecktask.cpp +++ b/lib/methods/ifwapichecktask.cpp @@ -105,7 +105,6 @@ static void DoIfwNetIo( sslConn.async_shutdown(yc[ec]); } - CpuBoundWork cbw (yc); Value jsonRoot; try { @@ -447,9 +446,12 @@ void IfwApiCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes auto conn (Shared::Make(io, *ctx, expectedSan)); + // Handler for the final check result that is used to asynchronously process within the global non-I/O thread pool. + auto handler ([cr, resultHandler = std::move(resultHandler)]() { resultHandler(cr); }); + IoEngine::SpawnCoroutine( *strand, - [strand, checkable, cr, cmdLine, psCommand, psHost, expectedSan, psPort, conn, req, checkTimeout, handler = std::move(resultHandler)](asio::yield_context yc) { + [strand, checkable, cr, psCommand, psHost, expectedSan, psPort, conn, req, checkTimeout, handler = std::move(handler)](asio::yield_context yc) { Timeout::Ptr timeout = new Timeout(strand->context(), *strand, boost::posix_time::microseconds(int64_t(checkTimeout * 1e6)), [&conn, &checkable](boost::asio::yield_context yc) { Log(LogNotice, "IfwApiCheckTask") @@ -466,7 +468,10 @@ void IfwApiCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes DoIfwNetIo(yc, cr, psCommand, psHost, expectedSan, psPort, *conn, *req); cr->SetExecutionEnd(Utility::GetTime()); - handler(cr); + + // Post the check result processing to the global pool not to block the I/O threads, + // which could affect processing important RPC messages and HTTP connections. + Utility::QueueAsyncCallback(std::ref(handler)); } ); }