iterator fix
This commit is contained in:
parent
ea4c11a52e
commit
b839dcaf1e
1 changed files with 12 additions and 10 deletions
20
src/Timer.cc
20
src/Timer.cc
|
@ -128,22 +128,24 @@ void BTimer::updateTimers(int fd) {
|
||||||
//must check end ...the timer might remove
|
//must check end ...the timer might remove
|
||||||
//it self from the list (should be fixed in the future)
|
//it self from the list (should be fixed in the future)
|
||||||
for(; it != m_timerlist.end(); ++it) {
|
for(; it != m_timerlist.end(); ++it) {
|
||||||
tm.tv_sec = (*it)->getStartTime().tv_sec +
|
//This is to make sure we don't get an invalid iterator
|
||||||
(*it)->getTimeout().tv_sec;
|
//when we do fireTimeout
|
||||||
tm.tv_usec = (*it)->getStartTime().tv_usec +
|
BTimer &t = *(*it);
|
||||||
(*it)->getTimeout().tv_usec;
|
tm.tv_sec = t.getStartTime().tv_sec +
|
||||||
|
t.getTimeout().tv_sec;
|
||||||
|
tm.tv_usec = t.getStartTime().tv_usec +
|
||||||
|
t.getTimeout().tv_usec;
|
||||||
|
|
||||||
if ((now.tv_sec < tm.tv_sec) ||
|
if ((now.tv_sec < tm.tv_sec) ||
|
||||||
(now.tv_sec == tm.tv_sec && now.tv_usec < tm.tv_usec))
|
(now.tv_sec == tm.tv_sec && now.tv_usec < tm.tv_usec))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
(*it)->fireTimeout();
|
t.fireTimeout();
|
||||||
|
|
||||||
// restart the current timer so that the start time is updated
|
// restart the current timer so that the start time is updated
|
||||||
if (! (*it)->doOnce())
|
if (! t.doOnce())
|
||||||
(*it)->start();
|
t.start();
|
||||||
else {
|
else {
|
||||||
(*it)->stop();
|
t.stop();
|
||||||
it--;
|
it--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue