BUFFER_PUSH(loop->timers) = NULL;
}
+void io_log_event(void *hook, void *data);
+
void
timers_fire(struct timeloop *loop)
{
else
tm2_stop(t);
+ /* This is ugly hack, we want to log just timers executed from the main I/O loop */
+ if (loop == &main_timeloop)
+ io_log_event(t->hook, t->data);
+
t->hook(t);
}
}
void
io_loop(void)
{
- int poll_tout;
+ int poll_tout, timeout;
time_t tout;
int nfds, events, pout;
+ timer2 *t;
sock *s;
node *n;
int fdmax = 256;
watchdog_start1();
for(;;)
{
+ times_update(&main_timeloop);
events = ev_run_list(&global_event_list);
+ timers_fire(&main_timeloop);
timers:
update_times();
tout = tm_first_shot();
tm_shot();
goto timers;
}
- poll_tout = (events ? 0 : MIN(tout - now, 3)) * 1000; /* Time in milliseconds */
-
io_close_event();
+ poll_tout = (events ? 0 : MIN(tout - now, 3)) * 1000; /* Time in milliseconds */
+ if (t = timers_first(&main_timeloop))
+ {
+ times_update(&main_timeloop);
+ timeout = (tm2_remains(t) TO_MS) + 1;
+ poll_tout = MIN(poll_tout, timeout);
+ }
+
nfds = 0;
WALK_LIST(n, sock_list)
{
}
if (pout)
{
+ times_update(&main_timeloop);
+
/* guaranteed to be non-empty */
current_sock = SKIP_BACK(sock, n, HEAD(sock_list));