diff --git a/lib/icingadb/redisconnection.cpp b/lib/icingadb/redisconnection.cpp index b125290bd..c51e891a8 100644 --- a/lib/icingadb/redisconnection.cpp +++ b/lib/icingadb/redisconnection.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -91,7 +92,7 @@ void RedisConnection::FireAndForgetQuery(RedisConnection::Query query, RedisConn LogQuery(query, msg); } - auto item (std::make_shared(std::move(query))); + auto item (Shared::Make(std::move(query))); asio::post(m_Strand, [this, item, priority]() { m_Queues.Writes[priority].emplace(WriteQueueItem{item, nullptr, nullptr, nullptr}); @@ -112,7 +113,7 @@ void RedisConnection::FireAndForgetQueries(RedisConnection::Queries queries, Red LogQuery(query, msg); } - auto item (std::make_shared(std::move(queries))); + auto item (Shared::Make(std::move(queries))); asio::post(m_Strand, [this, item, priority]() { m_Queues.Writes[priority].emplace(WriteQueueItem{nullptr, item, nullptr, nullptr}); @@ -137,7 +138,7 @@ RedisConnection::Reply RedisConnection::GetResultOfQuery(RedisConnection::Query std::promise promise; auto future (promise.get_future()); - auto item (std::make_shared(std::move(query), std::move(promise))); + auto item (Shared>>::Make(std::move(query), std::move(promise))); asio::post(m_Strand, [this, item, priority]() { m_Queues.Writes[priority].emplace(WriteQueueItem{nullptr, nullptr, item, nullptr}); @@ -166,7 +167,7 @@ RedisConnection::Replies RedisConnection::GetResultsOfQueries(RedisConnection::Q std::promise promise; auto future (promise.get_future()); - auto item (std::make_shared(std::move(queries), std::move(promise))); + auto item (Shared>>::Make(std::move(queries), std::move(promise))); asio::post(m_Strand, [this, item, priority]() { m_Queues.Writes[priority].emplace(WriteQueueItem{nullptr, nullptr, nullptr, item}); @@ -193,14 +194,14 @@ void RedisConnection::Connect(asio::yield_context& yc) Log(LogInformation, "IcingaDB") << "Trying to connect to Redis server (async) on host '" << m_Host << ":" << m_Port << "'"; - decltype(m_TcpConn) conn (new TcpConn(m_Strand.context())); + auto conn (Shared::Make(m_Strand.context())); icinga::Connect(conn->next_layer(), m_Host, Convert::ToString(m_Port), yc); m_TcpConn = std::move(conn); } else { Log(LogInformation, "IcingaDB") << "Trying to connect to Redis server (async) on unix socket path '" << m_Path << "'"; - decltype(m_UnixConn) conn (new UnixConn(m_Strand.context())); + auto conn (Shared::Make(m_Strand.context())); conn->next_layer().async_connect(Unix::endpoint(m_Path.CStr()), yc); m_UnixConn = std::move(conn); } diff --git a/lib/icingadb/redisconnection.hpp b/lib/icingadb/redisconnection.hpp index 60a6283d5..3cb5956cf 100644 --- a/lib/icingadb/redisconnection.hpp +++ b/lib/icingadb/redisconnection.hpp @@ -7,6 +7,7 @@ #include "base/atomic.hpp" #include "base/io-engine.hpp" #include "base/object.hpp" +#include "base/shared.hpp" #include "base/string.hpp" #include "base/value.hpp" #include @@ -109,10 +110,10 @@ namespace icinga */ struct WriteQueueItem { - std::shared_ptr FireAndForgetQuery; - std::shared_ptr FireAndForgetQueries; - std::shared_ptr>> GetResultOfQuery; - std::shared_ptr>> GetResultsOfQueries; + Shared::Ptr FireAndForgetQuery; + Shared::Ptr FireAndForgetQueries; + Shared>>::Ptr GetResultOfQuery; + Shared>>::Ptr GetResultsOfQueries; }; typedef boost::asio::ip::tcp Tcp; @@ -155,8 +156,8 @@ namespace icinga int m_DbIndex; boost::asio::io_context::strand m_Strand; - std::shared_ptr m_TcpConn; - std::shared_ptr m_UnixConn; + Shared::Ptr m_TcpConn; + Shared::Ptr m_UnixConn; Atomic m_Connecting, m_Connected, m_Started; struct {