mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 19:04:32 +02:00
fix an idiotic bug with silent node kill thread
This commit is contained in:
parent
60095bcbca
commit
13ac5472ea
2 changed files with 15 additions and 5 deletions
|
@ -542,14 +542,17 @@ Node* NodeList::soloNodeOfType(char nodeType) {
|
|||
|
||||
void* removeSilentNodes(void *args) {
|
||||
NodeList* nodeList = (NodeList*) args;
|
||||
uint64_t checkTimeUsecs = usecTimestampNow();
|
||||
int sleepTime;
|
||||
uint64_t checkTimeUsecs = 0;
|
||||
int sleepTime = 0;
|
||||
|
||||
while (!silentNodeThreadStopFlag) {
|
||||
|
||||
checkTimeUsecs = usecTimestampNow();
|
||||
|
||||
for(NodeList::iterator node = nodeList->begin(); node != nodeList->end(); ++node) {
|
||||
|
||||
node->lock();
|
||||
|
||||
qDebug() << usecTimestampNow() - node->getLastHeardMicrostamp() << "\n";
|
||||
|
||||
if ((usecTimestampNow() - node->getLastHeardMicrostamp()) > NODE_SILENCE_THRESHOLD_USECS) {
|
||||
|
||||
|
@ -564,10 +567,17 @@ void* removeSilentNodes(void *args) {
|
|||
}
|
||||
|
||||
sleepTime = NODE_SILENCE_THRESHOLD_USECS - (usecTimestampNow() - checkTimeUsecs);
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
Sleep( static_cast<int>(1000.0f*sleepTime) );
|
||||
|
||||
#else
|
||||
usleep(sleepTime);
|
||||
|
||||
if (sleepTime > 0) {
|
||||
usleep(sleepTime);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ const int NODES_PER_BUCKET = 100;
|
|||
|
||||
const int MAX_PACKET_SIZE = 1500;
|
||||
|
||||
const uint64_t NODE_SILENCE_THRESHOLD_USECS = 2 * 1000000;
|
||||
const uint64_t NODE_SILENCE_THRESHOLD_USECS = 2 * 1000 * 1000;
|
||||
const int DOMAIN_SERVER_CHECK_IN_USECS = 1 * 1000000;
|
||||
|
||||
extern const char SOLO_NODE_TYPES[2];
|
||||
|
|
Loading…
Reference in a new issue