From 8dd6bc2c55f91c0d3048822bb25f6b668e22da3d Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sat, 17 Aug 2019 16:17:49 +0300 Subject: [PATCH] Make ownership of SocketMultiplexer explicit --- src/lib/barrier/App.cpp | 2 +- src/lib/barrier/App.h | 8 +++++--- src/lib/barrier/ClientApp.cpp | 3 +-- src/lib/barrier/ServerApp.cpp | 3 +-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/lib/barrier/App.cpp b/src/lib/barrier/App.cpp index f4293b63..8a79aa2c 100644 --- a/src/lib/barrier/App.cpp +++ b/src/lib/barrier/App.cpp @@ -200,7 +200,7 @@ App::initApp(int argc, const char** argv) void App::initIpcClient() { - m_ipcClient = new IpcClient(m_events, m_socketMultiplexer); + m_ipcClient = new IpcClient(m_events, m_socketMultiplexer.get()); m_ipcClient->connect(); m_events->adoptHandler( diff --git a/src/lib/barrier/App.h b/src/lib/barrier/App.h index b7c77a00..8040da86 100644 --- a/src/lib/barrier/App.h +++ b/src/lib/barrier/App.h @@ -23,7 +23,9 @@ #include "base/String.h" #include "base/Log.h" #include "base/EventQueue.h" +#include "net/SocketMultiplexer.h" #include "common/common.h" +#include #if SYSAPI_WIN32 #include "barrier/win32/AppUtilWindows.h" @@ -95,8 +97,8 @@ public: virtual IEventQueue* getEvents() const { return m_events; } - void setSocketMultiplexer(SocketMultiplexer* sm) { m_socketMultiplexer = sm; } - SocketMultiplexer* getSocketMultiplexer() const { return m_socketMultiplexer; } + void setSocketMultiplexer(std::unique_ptr&& sm) { m_socketMultiplexer = std::move(sm); } + SocketMultiplexer* getSocketMultiplexer() const { return m_socketMultiplexer.get(); } void setEvents(EventQueue& events) { m_events = &events; } @@ -119,7 +121,7 @@ private: CreateTaskBarReceiverFunc m_createTaskBarReceiver; ARCH_APP_UTIL m_appUtil; IpcClient* m_ipcClient; - SocketMultiplexer* m_socketMultiplexer; + std::unique_ptr m_socketMultiplexer; }; class MinimalApp : public App { diff --git a/src/lib/barrier/ClientApp.cpp b/src/lib/barrier/ClientApp.cpp index 15416f60..a91312d8 100644 --- a/src/lib/barrier/ClientApp.cpp +++ b/src/lib/barrier/ClientApp.cpp @@ -443,8 +443,7 @@ ClientApp::mainLoop() { // create socket multiplexer. this must happen after daemonization // on unix because threads evaporate across a fork(). - SocketMultiplexer multiplexer; - setSocketMultiplexer(&multiplexer); + setSocketMultiplexer(std::make_unique()); // start client, etc appUtil().startNode(); diff --git a/src/lib/barrier/ServerApp.cpp b/src/lib/barrier/ServerApp.cpp index d91e094b..318673ca 100644 --- a/src/lib/barrier/ServerApp.cpp +++ b/src/lib/barrier/ServerApp.cpp @@ -713,8 +713,7 @@ ServerApp::mainLoop() { // create socket multiplexer. this must happen after daemonization // on unix because threads evaporate across a fork(). - SocketMultiplexer multiplexer; - setSocketMultiplexer(&multiplexer); + setSocketMultiplexer(std::make_unique()); // if configuration has no screens then add this system // as the default