From 42a33cdc7d9277b63f6e6ddb01e28dfb5f2b8dd6 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 7 Jun 2019 16:30:34 +0200 Subject: [PATCH] Fix build errors with Boost v1.70 refs #7237 --- lib/base/tcpsocket.hpp | 5 +++-- lib/remote/apilistener.cpp | 4 ++-- lib/remote/httpserverconnection.cpp | 11 +++++++++-- lib/remote/httpserverconnection.hpp | 3 +++ lib/remote/jsonrpcconnection.cpp | 15 +++++++++++---- lib/remote/jsonrpcconnection.hpp | 4 +++- 6 files changed, 31 insertions(+), 11 deletions(-) diff --git a/lib/base/tcpsocket.hpp b/lib/base/tcpsocket.hpp index 5b0a9077c..5c6a9fcb9 100644 --- a/lib/base/tcpsocket.hpp +++ b/lib/base/tcpsocket.hpp @@ -4,6 +4,7 @@ #define TCPSOCKET_H #include "base/i2-base.hpp" +#include "base/io-engine.hpp" #include "base/socket.hpp" #include #include @@ -37,7 +38,7 @@ void Connect(Socket& socket, const String& node, const String& service) { using boost::asio::ip::tcp; - tcp::resolver resolver (socket.get_executor().context()); + tcp::resolver resolver (IoEngine::Get().GetIoService()); tcp::resolver::query query (node, service); auto result (resolver.resolve(query)); auto current (result.begin()); @@ -66,7 +67,7 @@ void Connect(Socket& socket, const String& node, const String& service, boost::a { using boost::asio::ip::tcp; - tcp::resolver resolver (socket.get_executor().context()); + tcp::resolver resolver (IoEngine::Get().GetIoService()); tcp::resolver::query query (node, service); auto result (resolver.async_resolve(query, yc)); auto current (result.begin()); diff --git a/lib/remote/apilistener.cpp b/lib/remote/apilistener.cpp index b31e70dfe..a7f0f66a7 100644 --- a/lib/remote/apilistener.cpp +++ b/lib/remote/apilistener.cpp @@ -417,7 +417,7 @@ void ApiListener::ListenerCoroutineProc(boost::asio::yield_context yc, const std { namespace asio = boost::asio; - auto& io (server->get_executor().context()); + auto& io (IoEngine::Get().GetIoService()); for (;;) { try { @@ -651,7 +651,7 @@ void ApiListener::NewClientHandlerInternal(boost::asio::yield_context yc, const endpoint->AddClient(aclient); - asio::spawn(client->get_executor().context(), [this, aclient, endpoint, needSync](asio::yield_context yc) { + asio::spawn(IoEngine::Get().GetIoService(), [this, aclient, endpoint, needSync](asio::yield_context yc) { CpuBoundWork syncClient (yc); SyncClient(aclient, endpoint, needSync); diff --git a/lib/remote/httpserverconnection.cpp b/lib/remote/httpserverconnection.cpp index dc042d16c..e2db0641e 100644 --- a/lib/remote/httpserverconnection.cpp +++ b/lib/remote/httpserverconnection.cpp @@ -12,6 +12,7 @@ #include "base/configtype.hpp" #include "base/defer.hpp" #include "base/exception.hpp" +#include "base/io-engine.hpp" #include "base/logger.hpp" #include "base/objectlock.hpp" #include "base/timer.hpp" @@ -20,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -31,8 +33,13 @@ using namespace icinga; auto const l_ServerHeader ("Icinga/" + Application::GetAppVersion()); HttpServerConnection::HttpServerConnection(const String& identity, bool authenticated, const std::shared_ptr& stream) - : m_Stream(stream), m_Seen(Utility::GetTime()), m_IoStrand(stream->get_executor().context()), m_ShuttingDown(false), m_HasStartedStreaming(false), - m_CheckLivenessTimer(stream->get_executor().context()) + : HttpServerConnection(identity, authenticated, stream, IoEngine::Get().GetIoService()) +{ +} + +HttpServerConnection::HttpServerConnection(const String& identity, bool authenticated, const std::shared_ptr& stream, boost::asio::io_service& io) + : m_Stream(stream), m_Seen(Utility::GetTime()), m_IoStrand(io), m_ShuttingDown(false), m_HasStartedStreaming(false), + m_CheckLivenessTimer(io) { if (authenticated) { m_ApiUser = ApiUser::GetByClientCN(identity); diff --git a/lib/remote/httpserverconnection.hpp b/lib/remote/httpserverconnection.hpp index 6586e0ff1..b697d5381 100644 --- a/lib/remote/httpserverconnection.hpp +++ b/lib/remote/httpserverconnection.hpp @@ -8,6 +8,7 @@ #include "base/tlsstream.hpp" #include #include +#include #include #include @@ -42,6 +43,8 @@ private: bool m_HasStartedStreaming; boost::asio::deadline_timer m_CheckLivenessTimer; + HttpServerConnection(const String& identity, bool authenticated, const std::shared_ptr& stream, boost::asio::io_service& io); + void ProcessMessages(boost::asio::yield_context yc); void CheckLiveness(boost::asio::yield_context yc); }; diff --git a/lib/remote/jsonrpcconnection.cpp b/lib/remote/jsonrpcconnection.cpp index 53c3c58e5..03902ca87 100644 --- a/lib/remote/jsonrpcconnection.cpp +++ b/lib/remote/jsonrpcconnection.cpp @@ -16,6 +16,7 @@ #include "base/tlsstream.hpp" #include #include +#include #include #include #include @@ -30,10 +31,16 @@ static RingBuffer l_TaskStats (15 * 60); JsonRpcConnection::JsonRpcConnection(const String& identity, bool authenticated, const std::shared_ptr& stream, ConnectionRole role) - : m_Identity(identity), m_Authenticated(authenticated), m_Stream(stream), - m_Role(role), m_Timestamp(Utility::GetTime()), m_Seen(Utility::GetTime()), m_NextHeartbeat(0), m_IoStrand(stream->get_executor().context()), - m_OutgoingMessagesQueued(stream->get_executor().context()), m_WriterDone(stream->get_executor().context()), m_ShuttingDown(false), - m_CheckLivenessTimer(stream->get_executor().context()), m_HeartbeatTimer(stream->get_executor().context()) + : JsonRpcConnection(identity, authenticated, stream, role, IoEngine::Get().GetIoService()) +{ +} + +JsonRpcConnection::JsonRpcConnection(const String& identity, bool authenticated, + const std::shared_ptr& stream, ConnectionRole role, boost::asio::io_service& io) + : m_Identity(identity), m_Authenticated(authenticated), m_Stream(stream), m_Role(role), + m_Timestamp(Utility::GetTime()), m_Seen(Utility::GetTime()), m_NextHeartbeat(0), m_IoStrand(io), + m_OutgoingMessagesQueued(io), m_WriterDone(io), m_ShuttingDown(false), + m_CheckLivenessTimer(io), m_HeartbeatTimer(io) { if (authenticated) m_Endpoint = Endpoint::GetByName(identity); diff --git a/lib/remote/jsonrpcconnection.hpp b/lib/remote/jsonrpcconnection.hpp index caca1cb72..2b1835308 100644 --- a/lib/remote/jsonrpcconnection.hpp +++ b/lib/remote/jsonrpcconnection.hpp @@ -11,7 +11,7 @@ #include "base/workqueue.hpp" #include #include -#include +#include #include #include @@ -80,6 +80,8 @@ private: bool m_ShuttingDown; boost::asio::deadline_timer m_CheckLivenessTimer, m_HeartbeatTimer; + JsonRpcConnection(const String& identity, bool authenticated, const std::shared_ptr& stream, ConnectionRole role, boost::asio::io_service& io); + void HandleIncomingMessages(boost::asio::yield_context yc); void WriteOutgoingMessages(boost::asio::yield_context yc); void HandleAndWriteHeartbeats(boost::asio::yield_context yc);