diff --git a/src/threading/Manager.cc b/src/threading/Manager.cc index 43eb0313f4..7481e83192 100644 --- a/src/threading/Manager.cc +++ b/src/threading/Manager.cc @@ -73,14 +73,11 @@ void Manager::GetFds(int* read, int* write, int* except) double Manager::NextTimestamp(double* network_time) { - if ( ::network_time && ! next_beat ) - next_beat = ::network_time + HEART_BEAT_INTERVAL; - // fprintf(stderr, "N %.6f %.6f did_process=%d next_next=%.6f\n", ::network_time, timer_mgr->Time(), (int)did_process, next_beat); - if ( did_process || ::network_time > next_beat ) + if ( did_process || ::network_time > next_beat || ! next_beat ) // If we had something to process last time (or out heartbeat - // is due), we want to check for more asap. + // is due or not set yet), we want to check for more asap. return timer_mgr->Time(); return -1.0; @@ -88,7 +85,13 @@ double Manager::NextTimestamp(double* network_time) void Manager::Process() { - bool do_beat = (next_beat && network_time > next_beat); + bool do_beat = false; + + if ( network_time && (network_time > next_beat || ! next_beat) ) + { + do_beat = true; + next_beat = ::network_time + HEART_BEAT_INTERVAL; + } did_process = false; @@ -97,10 +100,7 @@ void Manager::Process() MsgThread* t = *i; if ( do_beat ) - { t->Heartbeat(); - next_beat = 0; - } while ( t->HasOut() ) {