fix an idiotic bug with silent node kill thread

This commit is contained in:
Stephen Birarda 2013-10-11 10:23:59 -07:00
parent 60095bcbca
commit 13ac5472ea
2 changed files with 15 additions and 5 deletions

View file

@ -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
}

View file

@ -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];