From 5dc467310ddebeae8dcb6262f5499f37382711ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Wed, 17 Feb 2021 22:15:27 +0100 Subject: WatchedHead object allowing to stop watching Head --- src/network.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/network.cpp') 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 w) Server::Priv::Priv(const Head & local, const Identity & self, vector> && 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 & 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() -- cgit v1.2.3