diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2019-08-04 19:55:52 -0700 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2019-08-04 19:55:52 -0700 |
| commit | a77b4ecddb43cd8581c7ebaeb8fcc9b5dac10573 (patch) | |
| tree | a594e06141299d32a4da746c6d5c214fb484100d /controller/LFDB.cpp | |
| parent | 818b7e4a2e35adfc241aed38e90b34580e6b5d9d (diff) | |
| download | infinitytier-a77b4ecddb43cd8581c7ebaeb8fcc9b5dac10573.tar.gz infinitytier-a77b4ecddb43cd8581c7ebaeb8fcc9b5dac10573.zip | |
Add optional function in DB change listener for member online events.
Diffstat (limited to 'controller/LFDB.cpp')
| -rw-r--r-- | controller/LFDB.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/controller/LFDB.cpp b/controller/LFDB.cpp index f0c8ebfb..999eca72 100644 --- a/controller/LFDB.cpp +++ b/controller/LFDB.cpp @@ -384,17 +384,24 @@ void LFDB::eraseMember(const uint64_t networkId,const uint64_t memberId) void LFDB::nodeIsOnline(const uint64_t networkId,const uint64_t memberId,const InetAddress &physicalAddress) { - std::lock_guard<std::mutex> l(_state_l); - auto nw = _state.find(networkId); - if (nw != _state.end()) { - auto m = nw->second.members.find(memberId); - if (m != nw->second.members.end()) { - m->second.lastOnlineTime = OSUtils::now(); - if (physicalAddress) - m->second.lastOnlineAddress = physicalAddress; - m->second.lastOnlineDirty = true; + { + std::lock_guard<std::mutex> l(_state_l); + auto nw = _state.find(networkId); + if (nw != _state.end()) { + auto m = nw->second.members.find(memberId); + if (m != nw->second.members.end()) { + m->second.lastOnlineTime = OSUtils::now(); + if (physicalAddress) + m->second.lastOnlineAddress = physicalAddress; + m->second.lastOnlineDirty = true; + } } } + { + std::lock_guard<std::mutex> l2(_changeListeners_l); + for(auto i=_changeListeners.begin();i!=_changeListeners.end();++i) + (*i)->onNetworkMemberOnline(networkId,memberId,physicalAddress); + } } } // namespace ZeroTier |
