diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2021-11-27 22:29:53 +0100 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2021-11-28 20:14:33 +0100 |
commit | 53f4c26c4682a951e084415a594fcb8d9494033f (patch) | |
tree | e9e7ed894303df434e3b8d6592fb805075fd9e73 | |
parent | 6810c0e213226a62db1179a7c55bd351eb71ffe9 (diff) |
Network: make Server non-copyable
Avoids issues with shared_from_this and does not make much sense anyway.
-rw-r--r-- | include/erebos/network.h | 3 | ||||
-rw-r--r-- | src/network.cpp | 3 | ||||
-rw-r--r-- | src/network.h | 2 |
3 files changed, 6 insertions, 2 deletions
diff --git a/include/erebos/network.h b/include/erebos/network.h index f2ae191..252c3c7 100644 --- a/include/erebos/network.h +++ b/include/erebos/network.h @@ -16,6 +16,9 @@ public: Server(const std::shared_ptr<Priv> &); ~Server(); + Server(const Server &) = delete; + Server & operator=(const Server &) = delete; + const Head<LocalState> & localHead() const; const Bhv<LocalState> & localState() const; diff --git a/src/network.cpp b/src/network.cpp index 2db450c..1e95571 100644 --- a/src/network.cpp +++ b/src/network.cpp @@ -269,7 +269,8 @@ Server::Priv::~Priv() shared_ptr<Server::Priv> Server::Priv::getptr() { - return shared_from_this(); + // Creating temporary object, so just use null deleter + return shared_ptr<Priv>(this, [](Priv *){}); } void Server::Priv::doListen() diff --git a/src/network.h b/src/network.h index c4f3d6f..b2cd8be 100644 --- a/src/network.h +++ b/src/network.h @@ -136,7 +136,7 @@ struct WaitingRef optional<Ref> check(ReplyBuilder &); }; -struct Server::Priv : enable_shared_from_this<Server::Priv> +struct Server::Priv { Priv(const Head<LocalState> & local, const Identity & self, vector<unique_ptr<Service>> && svcs); |