mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-28 08:04:14 +02:00
Merge pull request #9994 from Icinga/redundant-cpu-bound-work-usages
Drop redundant `CpuBoundWork` usages in `lib/remote`
This commit is contained in:
commit
fc6a106345
@ -116,16 +116,12 @@ bool EventsHandler::HandleRequest(
|
|||||||
auto event (subscriber.GetInbox()->Shift(yc));
|
auto event (subscriber.GetInbox()->Shift(yc));
|
||||||
|
|
||||||
if (event) {
|
if (event) {
|
||||||
CpuBoundWork buildingResponse (yc);
|
|
||||||
|
|
||||||
String body = JsonEncode(event);
|
String body = JsonEncode(event);
|
||||||
|
|
||||||
boost::algorithm::replace_all(body, "\n", "");
|
boost::algorithm::replace_all(body, "\n", "");
|
||||||
|
|
||||||
asio::const_buffer payload (body.CStr(), body.GetLength());
|
asio::const_buffer payload (body.CStr(), body.GetLength());
|
||||||
|
|
||||||
buildingResponse.Done();
|
|
||||||
|
|
||||||
asio::async_write(stream, payload, yc);
|
asio::async_write(stream, payload, yc);
|
||||||
asio::async_write(stream, newLine, yc);
|
asio::async_write(stream, newLine, yc);
|
||||||
stream.async_flush(yc);
|
stream.async_flush(yc);
|
||||||
|
@ -102,8 +102,6 @@ void HttpServerConnection::Disconnect()
|
|||||||
auto listener (ApiListener::GetInstance());
|
auto listener (ApiListener::GetInstance());
|
||||||
|
|
||||||
if (listener) {
|
if (listener) {
|
||||||
CpuBoundWork removeHttpClient (yc);
|
|
||||||
|
|
||||||
listener->RemoveHttpClient(this);
|
listener->RemoveHttpClient(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -240,8 +238,6 @@ bool HandleAccessControl(
|
|||||||
auto headerAllowOrigin (listener->GetAccessControlAllowOrigin());
|
auto headerAllowOrigin (listener->GetAccessControlAllowOrigin());
|
||||||
|
|
||||||
if (headerAllowOrigin) {
|
if (headerAllowOrigin) {
|
||||||
CpuBoundWork allowOriginHeader (yc);
|
|
||||||
|
|
||||||
auto allowedOrigins (headerAllowOrigin->ToSet<String>());
|
auto allowedOrigins (headerAllowOrigin->ToSet<String>());
|
||||||
|
|
||||||
if (!allowedOrigins.empty()) {
|
if (!allowedOrigins.empty()) {
|
||||||
@ -251,8 +247,6 @@ bool HandleAccessControl(
|
|||||||
response.set(http::field::access_control_allow_origin, origin);
|
response.set(http::field::access_control_allow_origin, origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
allowOriginHeader.Done();
|
|
||||||
|
|
||||||
response.set(http::field::access_control_allow_credentials, "true");
|
response.set(http::field::access_control_allow_credentials, "true");
|
||||||
|
|
||||||
if (request.method() == http::verb::options && !request[http::field::access_control_request_method].empty()) {
|
if (request.method() == http::verb::options && !request[http::field::access_control_request_method].empty()) {
|
||||||
@ -537,8 +531,6 @@ void HttpServerConnection::ProcessMessages(boost::asio::yield_context yc)
|
|||||||
auto authenticatedUser (m_ApiUser);
|
auto authenticatedUser (m_ApiUser);
|
||||||
|
|
||||||
if (!authenticatedUser) {
|
if (!authenticatedUser) {
|
||||||
CpuBoundWork fetchingAuthenticatedUser (yc);
|
|
||||||
|
|
||||||
authenticatedUser = ApiUser::GetByAuthHeader(std::string(request[http::field::authorization]));
|
authenticatedUser = ApiUser::GetByAuthHeader(std::string(request[http::field::authorization]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,6 +81,8 @@ void JsonRpcConnection::HandleIncomingMessages(boost::asio::yield_context yc)
|
|||||||
CpuBoundWork handleMessage (yc);
|
CpuBoundWork handleMessage (yc);
|
||||||
|
|
||||||
MessageHandler(message);
|
MessageHandler(message);
|
||||||
|
|
||||||
|
l_TaskStats.InsertValue(Utility::GetTime(), 1);
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
Log(m_ShuttingDown ? LogDebug : LogWarning, "JsonRpcConnection")
|
Log(m_ShuttingDown ? LogDebug : LogWarning, "JsonRpcConnection")
|
||||||
<< "Error while processing JSON-RPC message for identity '" << m_Identity
|
<< "Error while processing JSON-RPC message for identity '" << m_Identity
|
||||||
@ -88,10 +90,6 @@ void JsonRpcConnection::HandleIncomingMessages(boost::asio::yield_context yc)
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
CpuBoundWork taskStats (yc);
|
|
||||||
|
|
||||||
l_TaskStats.InsertValue(Utility::GetTime(), 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Disconnect();
|
Disconnect();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user