summaryrefslogtreecommitdiff
path: root/src/network.cpp
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2021-02-17 22:15:27 +0100
committerRoman Smrž <roman.smrz@seznam.cz>2021-02-19 19:40:58 +0100
commit5dc467310ddebeae8dcb6262f5499f37382711ab (patch)
tree77dc6c6fd0abec84246aaacfbf5a8d471081e2ae /src/network.cpp
parentd42ed33bb9112d80ae9adc926b7bd818a4d35f8d (diff)
WatchedHead object allowing to stop watching Head
Diffstat (limited to 'src/network.cpp')
-rw-r--r--src/network.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/network.cpp b/src/network.cpp
index 74783b4..f33c097 100644
--- a/src/network.cpp
+++ b/src/network.cpp
@@ -201,8 +201,9 @@ void PeerList::onUpdate(function<void(size_t, const Peer *)> w)
Server::Priv::Priv(const Head<LocalState> & local, const Identity & self,
vector<unique_ptr<Service>> && svcs):
- localHead(local),
self(self),
+ // Watching needs to start after self is initialized
+ localHead(local.watch(std::bind(&Priv::handleLocalHeadChange, this, std::placeholders::_1))),
services(std::move(svcs))
{
struct ifaddrs * raddrs;
@@ -238,8 +239,6 @@ Server::Priv::Priv(const Head<LocalState> & local, const Identity & self,
threadListen = thread([this] { doListen(); });
threadAnnounce = thread([this] { doAnnounce(); });
-
- local.watch(std::bind(&Priv::handleLocalHeadChange, this, std::placeholders::_1));
}
Server::Priv::~Priv()