Skip to content

Commit

Permalink
IfwApiCheckTask: Process final cr in the global thread pool
Browse files Browse the repository at this point in the history
  • Loading branch information
yhabteab committed Sep 4, 2024
1 parent 850ed9a commit e866554
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/methods/ifwapichecktask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ static void DoIfwNetIo(
sslConn.async_shutdown(yc[ec]);
}

CpuBoundWork cbw (yc);
Value jsonRoot;

try {
Expand Down Expand Up @@ -446,9 +445,12 @@ void IfwApiCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes

auto conn (Shared<AsioTlsStream>::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 ([cmdLine, resultHandler = std::move(resultHandler)]() { resultHandler(cmdLine, ProcessResult{}); });

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")
Expand All @@ -465,7 +467,10 @@ void IfwApiCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes
DoIfwNetIo(yc, cr, psCommand, psHost, expectedSan, psPort, *conn, *req);

cr->SetExecutionEnd(Utility::GetTime());
handler(cmdLine, ProcessResult{});

// 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(handler);
}
);
}

0 comments on commit e866554

Please sign in to comment.