Handling of soon-to-expire members

This commit is contained in:
Adam Ierymenko 2021-07-23 18:49:00 -04:00
parent 8885149cd3
commit 34de579c91
No known key found for this signature in database
GPG key ID: C8877CF2D7A5D7F3
5 changed files with 83 additions and 8 deletions

View file

@ -1815,17 +1815,37 @@ void EmbeddedNetworkController::_startThreads()
_threads.emplace_back([this]() {
for(;;) {
_RQEntry *qe = (_RQEntry *)0;
if (!_queue.get(qe))
auto timedWaitResult = _queue.get(qe, 1000);
if (timedWaitResult == BlockingQueue<_RQEntry *>::STOP) {
break;
try {
} else if (timedWaitResult == BlockingQueue<_RQEntry *>::OK) {
if (qe) {
_request(qe->nwid,qe->fromAddr,qe->requestPacketId,qe->identity,qe->metaData);
try {
_request(qe->nwid,qe->fromAddr,qe->requestPacketId,qe->identity,qe->metaData);
} catch (std::exception &e) {
fprintf(stderr,"ERROR: exception in controller request handling thread: %s" ZT_EOL_S,e.what());
} catch ( ... ) {
fprintf(stderr,"ERROR: exception in controller request handling thread: unknown exception" ZT_EOL_S);
}
delete qe;
}
} catch (std::exception &e) {
fprintf(stderr,"ERROR: exception in controller request handling thread: %s" ZT_EOL_S,e.what());
} catch ( ... ) {
fprintf(stderr,"ERROR: exception in controller request handling thread: unknown exception" ZT_EOL_S);
}
auto expiringSoon = _db.membersExpiringSoon();
for(auto soon=expiringSoon.begin();soon!=expiringSoon.end();++soon) {
Identity identity;
Dictionary<ZT_NETWORKCONFIG_METADATA_DICT_CAPACITY> lastMetaData;
{
std::unique_lock<std::mutex> ll(_memberStatus_l);
auto ms = _memberStatus.find(_MemberStatusKey(soon->first, soon->second));
if (ms != _memberStatus.end()) {
lastMetaData = ms->second.lastRequestMetaData;
identity = ms->second.identity;
}
}
if (identity) {
request(soon->first,InetAddress(),0,identity,lastMetaData);
}
}
}
});