diff --git a/lib/base/io-engine.cpp b/lib/base/io-engine.cpp index b8908a313..aa20a1052 100644 --- a/lib/base/io-engine.cpp +++ b/lib/base/io-engine.cpp @@ -16,7 +16,7 @@ using namespace icinga; -CpuBoundWork::CpuBoundWork(boost::asio::yield_context yc) +CpuBoundWork::CpuBoundWork(boost::asio::yield_context yc, boost::asio::io_context::strand&) : m_Done(false) { auto& ioEngine (IoEngine::Get()); diff --git a/lib/base/io-engine.hpp b/lib/base/io-engine.hpp index 4fe34debf..c215b0a30 100644 --- a/lib/base/io-engine.hpp +++ b/lib/base/io-engine.hpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #if BOOST_VERSION >= 108700 @@ -37,7 +38,7 @@ namespace icinga class CpuBoundWork { public: - CpuBoundWork(boost::asio::yield_context yc); + CpuBoundWork(boost::asio::yield_context yc, boost::asio::io_context::strand&); CpuBoundWork(const CpuBoundWork&) = delete; CpuBoundWork(CpuBoundWork&&) = delete; CpuBoundWork& operator=(const CpuBoundWork&) = delete; diff --git a/lib/remote/httpserverconnection.cpp b/lib/remote/httpserverconnection.cpp index de2e46dd3..946e4e22c 100644 --- a/lib/remote/httpserverconnection.cpp +++ b/lib/remote/httpserverconnection.cpp @@ -413,13 +413,14 @@ void ProcessRequest( HttpResponse& response, const WaitGroup::Ptr& waitGroup, std::chrono::steady_clock::duration& cpuBoundWorkTime, - boost::asio::yield_context& yc + boost::asio::yield_context& yc, + boost::asio::io_context::strand& strand ) { try { // Cache the elapsed time to acquire a CPU semaphore used to detect extremely heavy workloads. auto start (std::chrono::steady_clock::now()); - auto handlingRequest (std::make_shared(yc)); + auto handlingRequest (std::make_shared(yc, strand)); cpuBoundWorkTime = std::chrono::steady_clock::now() - start; response.SetCpuBoundWork(handlingRequest); @@ -522,7 +523,7 @@ void HttpServerConnection::ProcessMessages(boost::asio::yield_context yc) m_Seen = std::numeric_limits::max(); - ProcessRequest(request, response, m_WaitGroup, cpuBoundWorkTime, yc); + ProcessRequest(request, response, m_WaitGroup, cpuBoundWorkTime, yc, m_IoStrand); if (!request.keep_alive() || !m_ConnectionReusable) { break; diff --git a/lib/remote/jsonrpcconnection.cpp b/lib/remote/jsonrpcconnection.cpp index b85944867..7e897b3e5 100644 --- a/lib/remote/jsonrpcconnection.cpp +++ b/lib/remote/jsonrpcconnection.cpp @@ -91,7 +91,7 @@ void JsonRpcConnection::HandleIncomingMessages(boost::asio::yield_context yc) auto start (ch::steady_clock::now()); try { - CpuBoundWork handleMessage (yc); + CpuBoundWork handleMessage (yc, m_IoStrand); // Cache the elapsed time to acquire a CPU semaphore used to detect extremely heavy workloads. cpuBoundDuration = ch::steady_clock::now() - start;