| 415 | |
| 416 | |
| 417 | static inline void timer_ticker(struct os_timer *tlist) |
| 418 | { |
| 419 | struct os_timer* t; |
| 420 | unsigned int j; |
| 421 | ssize_t l; |
| 422 | |
| 423 | /* we need to store the original time as while executing the |
| 424 | the handlers, the time may pass, affecting the way we |
| 425 | calculate the new expire (expire will include the time |
| 426 | taken to run handlers) -bogdan */ |
| 427 | j = *jiffies; |
| 428 | |
| 429 | for (t=tlist;t; t=t->next){ |
| 430 | if (j < t->expires) |
| 431 | continue; |
| 432 | |
| 433 | if (t->trigger_time) { |
| 434 | LM_WARN("timer task <%s> already scheduled %lld ms ago" |
| 435 | " (now %lld ms), %s\n", t->label, ((utime_t)*ijiffies/1000) - |
| 436 | (utime_t)(t->trigger_time/1000), ((utime_t)*ijiffies/1000), |
| 437 | t->flags&TIMER_FLAG_SKIP_ON_DELAY ? "skipping execution" : |
| 438 | t->flags&TIMER_FLAG_DELAY_ON_DELAY ? "delaying execution" : |
| 439 | "pushing a new one"); |
| 440 | |
| 441 | if (t->flags&TIMER_FLAG_SKIP_ON_DELAY) { |
| 442 | /* skip this execution of the timer handler */ |
| 443 | t->expires = j + t->interval; |
| 444 | continue; |
| 445 | } else if (t->flags&TIMER_FLAG_DELAY_ON_DELAY) { |
| 446 | /* delay and merge the executions of the timer handler |
| 447 | until the prev one is done */ |
| 448 | continue; |
| 449 | } else { |
| 450 | /* launch the task now, even if overlapping with the |
| 451 | already running one */ |
| 452 | } |
| 453 | } |
| 454 | t->expires = j + t->interval; |
| 455 | t->trigger_time = *ijiffies; |
| 456 | t->time = j; |
| 457 | /* push the jobs for execution */ |
| 458 | again: |
| 459 | l = write( timer_pipe[1], &t, sizeof(t)); |
| 460 | if (l==-1) { |
| 461 | if (errno==EAGAIN || errno==EINTR || errno==EWOULDBLOCK ) |
| 462 | goto again; |
| 463 | LM_ERR("writing failed:[%d] %s, skipping job <%s> at %d s\n", |
| 464 | errno, strerror(errno),t->label, j); |
| 465 | } |
| 466 | } |
| 467 | } |
| 468 | |
| 469 | |
| 470 | |