- g_assert(source);
- g_assert(timeout);
-
- if (!q->prioq->root) {
- *timeout = -1;
- return FALSE;
- }
-
- e = q->prioq->root->data;
- g_assert(e);
-
- source_get_timeval(source, &now);
-
- if (avahi_timeval_compare(&now, &e->expiry) >= 0 && /* Time elapsed */
- avahi_timeval_compare(&now, &e->last_run) != 0 /* Not yet run */) {
- *timeout = -1;
- return TRUE;
- }
-
- *timeout = (gint) (avahi_timeval_diff(&e->expiry, &now)/1000);
-
- /* Wait at least 1 msec */
- if (*timeout <= 0)
- *timeout = 1;
-
- return FALSE;
+ if ((e = time_event_queue_root(q)))
+ q->poll_api->timeout_update(q->timeout, &e->expiry);
+ else
+ q->poll_api->timeout_update(q->timeout, NULL);