| 211 | } |
| 212 | |
| 213 | void |
| 214 | tmr_run(struct timeval *nowP) |
| 215 | { |
| 216 | int h; |
| 217 | Timer *t; |
| 218 | Timer *next; |
| 219 | |
| 220 | for (h = 0; h < HASH_SIZE; ++h) |
| 221 | for (t = timers[h]; t != (Timer *)0; t = next) { |
| 222 | next = t->next; |
| 223 | /* Since the lists are sorted, as soon as we find a timer |
| 224 | ** that isn't ready yet, we can go on to the next list. |
| 225 | */ |
| 226 | if (t->time.tv_sec > nowP->tv_sec || (t->time.tv_sec == nowP->tv_sec && t->time.tv_usec > nowP->tv_usec)) |
| 227 | break; |
| 228 | |
| 229 | /* Invalidate mstimeout cache, since we're modifying the queue */ |
| 230 | mstimeout_cache = -1; |
| 231 | |
| 232 | (t->timer_proc)(t->client_data, nowP); |
| 233 | if (t->periodic) { |
| 234 | /* Reschedule. */ |
| 235 | t->time.tv_sec += t->msecs / 1000L; |
| 236 | t->time.tv_usec += (t->msecs % 1000L) * 1000L; |
| 237 | if (t->time.tv_usec >= 1000000L) { |
| 238 | t->time.tv_sec += t->time.tv_usec / 1000000L; |
| 239 | t->time.tv_usec %= 1000000L; |
| 240 | } |
| 241 | l_resort(t); |
| 242 | } else |
| 243 | tmr_cancel(t); |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | void |
| 248 | tmr_reset(struct timeval *nowP, Timer *t) |
no test coverage detected