diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2017-02-25 14:08:03 -0500 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2017-03-10 10:47:39 +0100 |
commit | 7fdb7a18616c6b8b2339df105629e251e79c6cf2 (patch) | |
tree | 804d8e18dc6181892826e9e06f539ff897cbb741 /net | |
parent | d9394d700093ab426ef305974a1115755840ade6 (diff) |
nb: StreamSocket takes ownership of SocketHandler instance
Change-Id: Ica99dc8afbcca71c8d79eecb276ba19f6f01fa57
Diffstat (limited to 'net')
-rw-r--r-- | net/Socket.hpp | 4 | ||||
-rw-r--r-- | net/SslSocket.hpp | 4 | ||||
-rw-r--r-- | net/loolnb.cpp | 12 |
3 files changed, 10 insertions, 10 deletions
diff --git a/net/Socket.hpp b/net/Socket.hpp index 8ad42e764..67c143527 100644 --- a/net/Socket.hpp +++ b/net/Socket.hpp @@ -338,9 +338,9 @@ class StreamSocket : public Socket { public: /// Create a StreamSocket from native FD and take ownership of handler instance. - StreamSocket(const int fd, SocketHandlerInterface* socketHandler) : + StreamSocket(const int fd, std::unique_ptr<SocketHandlerInterface> socketHandler) : Socket(fd), - _socketHandler(socketHandler), + _socketHandler(std::move(socketHandler)), _closed(false) { // Without a handler we make no sense. diff --git a/net/SslSocket.hpp b/net/SslSocket.hpp index 87b4b339b..0f43869d2 100644 --- a/net/SslSocket.hpp +++ b/net/SslSocket.hpp @@ -21,8 +21,8 @@ class SslStreamSocket : public StreamSocket { public: - SslStreamSocket(const int fd, SocketHandlerInterface* responseClient) : - StreamSocket(fd, responseClient), + SslStreamSocket(const int fd, std::unique_ptr<SocketHandlerInterface> responseClient) : + StreamSocket(fd, std::move(responseClient)), _ssl(nullptr), _sslWantsTo(SslWantsTo::ReadOrWrite), _doHandshake(true) diff --git a/net/loolnb.cpp b/net/loolnb.cpp index 489cfa7ca..b2f3cca2e 100644 --- a/net/loolnb.cpp +++ b/net/loolnb.cpp @@ -177,17 +177,17 @@ public: class PlainSocketFactory : public SocketFactory { std::shared_ptr<Socket> create(const int fd) override - { - return std::make_shared<StreamSocket>(fd, new SimpleResponseClient()); - } + { + return std::make_shared<StreamSocket>(fd, std::unique_ptr<SocketHandlerInterface>{ new SimpleResponseClient }); + } }; class SslSocketFactory : public SocketFactory { std::shared_ptr<Socket> create(const int fd) override - { - return std::make_shared<SslStreamSocket>(fd, new SimpleResponseClient()); - } + { + return std::make_shared<SslStreamSocket>(fd, std::unique_ptr<SocketHandlerInterface>{ new SimpleResponseClient }); + } }; |