From 5636f7cb26ffb383d5def054aad8986cd7e12ace Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
Date: Thu, 14 Sep 2023 14:34:57 -0400
Subject: [PATCH] MultiplexedSocket: add logger argument

Change-Id: I1c872351cf3f0e519595ab8d734db2841d7d2218
---
 include/multiplexed_socket.h | 2 +-
 src/connectionmanager.cpp    | 2 +-
 src/multiplexed_socket.cpp   | 7 ++++---
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/include/multiplexed_socket.h b/include/multiplexed_socket.h
index a090a8c..e265db9 100644
--- a/include/multiplexed_socket.h
+++ b/include/multiplexed_socket.h
@@ -79,7 +79,7 @@ struct ChannelRequest
 class MultiplexedSocket : public std::enable_shared_from_this<MultiplexedSocket>
 {
 public:
-    MultiplexedSocket(std::shared_ptr<asio::io_context> ctx, const DeviceId& deviceId, std::unique_ptr<TlsSocketEndpoint> endpoint);
+    MultiplexedSocket(std::shared_ptr<asio::io_context> ctx, const DeviceId& deviceId, std::unique_ptr<TlsSocketEndpoint> endpoint, std::shared_ptr<dht::log::Logger> logger = {});
     ~MultiplexedSocket();
     std::shared_ptr<ChannelSocket> addChannel(const std::string& name);
 
diff --git a/src/connectionmanager.cpp b/src/connectionmanager.cpp
index 2b6e544..f852661 100644
--- a/src/connectionmanager.cpp
+++ b/src/connectionmanager.cpp
@@ -1256,7 +1256,7 @@ ConnectionManager::Impl::onDhtPeerRequest(const PeerConnectionRequest& req,
 void
 ConnectionManager::Impl::addNewMultiplexedSocket(const CallbackId& id, const std::shared_ptr<ConnectionInfo>& info)
 {
-    info->socket_ = std::make_shared<MultiplexedSocket>(config_->ioContext, id.first, std::move(info->tls_));
+    info->socket_ = std::make_shared<MultiplexedSocket>(config_->ioContext, id.first, std::move(info->tls_), config_->logger);
     info->socket_->setOnReady(
         [w = weak()](const DeviceId& deviceId, const std::shared_ptr<ChannelSocket>& socket) {
             if (auto sthis = w.lock())
diff --git a/src/multiplexed_socket.cpp b/src/multiplexed_socket.cpp
index 28e5c11..154741b 100644
--- a/src/multiplexed_socket.cpp
+++ b/src/multiplexed_socket.cpp
@@ -60,7 +60,8 @@ public:
     Impl(MultiplexedSocket& parent,
          std::shared_ptr<asio::io_context> ctx,
          const DeviceId& deviceId,
-         std::unique_ptr<TlsSocketEndpoint> endpoint)
+         std::unique_ptr<TlsSocketEndpoint> endpoint,
+         std::shared_ptr<dht::log::Logger> logger)
         : parent_(parent)
         , ctx_(std::move(ctx))
         , deviceId(deviceId)
@@ -541,8 +542,8 @@ MultiplexedSocket::Impl::handleProtocolPacket(std::vector<uint8_t>&& pkt)
 }
 
 MultiplexedSocket::MultiplexedSocket(std::shared_ptr<asio::io_context> ctx, const DeviceId& deviceId,
-                                     std::unique_ptr<TlsSocketEndpoint> endpoint)
-    : pimpl_(std::make_unique<Impl>(*this, ctx, deviceId, std::move(endpoint)))
+                                     std::unique_ptr<TlsSocketEndpoint> endpoint, std::shared_ptr<dht::log::Logger> logger)
+    : pimpl_(std::make_unique<Impl>(*this, ctx, deviceId, std::move(endpoint), logger))
 {}
 
 MultiplexedSocket::~MultiplexedSocket() {}
-- 
GitLab