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 91fabbb commit eaf923d
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 @@ -447,9 +446,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 ([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")
Expand All @@ -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));
}
);
}

0 comments on commit eaf923d

Please sign in to comment.