aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Timer.cc22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/Timer.cc b/src/Timer.cc
index 876e53f..79b0939 100644
--- a/src/Timer.cc
+++ b/src/Timer.cc
@@ -128,22 +128,24 @@ void BTimer::updateTimers(int fd) {
128 //must check end ...the timer might remove 128 //must check end ...the timer might remove
129 //it self from the list (should be fixed in the future) 129 //it self from the list (should be fixed in the future)
130 for(; it != m_timerlist.end(); ++it) { 130 for(; it != m_timerlist.end(); ++it) {
131 tm.tv_sec = (*it)->getStartTime().tv_sec + 131 //This is to make sure we don't get an invalid iterator
132 (*it)->getTimeout().tv_sec; 132 //when we do fireTimeout
133 tm.tv_usec = (*it)->getStartTime().tv_usec + 133 BTimer &t = *(*it);
134 (*it)->getTimeout().tv_usec; 134 tm.tv_sec = t.getStartTime().tv_sec +
135 t.getTimeout().tv_sec;
136 tm.tv_usec = t.getStartTime().tv_usec +
137 t.getTimeout().tv_usec;
135 138
136 if ((now.tv_sec < tm.tv_sec) || 139 if ((now.tv_sec < tm.tv_sec) ||
137 (now.tv_sec == tm.tv_sec && now.tv_usec < tm.tv_usec)) 140 (now.tv_sec == tm.tv_sec && now.tv_usec < tm.tv_usec))
138 break; 141 break;
139 142
140 (*it)->fireTimeout(); 143 t.fireTimeout();
141
142 // restart the current timer so that the start time is updated 144 // restart the current timer so that the start time is updated
143 if (! (*it)->doOnce()) 145 if (! t.doOnce())
144 (*it)->start(); 146 t.start();
145 else { 147 else {
146 (*it)->stop(); 148 t.stop();
147 it--; 149 it--;
148 } 150 }
149 } 151 }