Commit 78887513 authored by Pekka Pessi's avatar Pekka Pessi

su_port.h, su_timer.c: refactored su_timer_next_expires()

Re-recorded 20071012131631-88462-46db2bef9a233efd0eb8ab2a4191d6fb407309ca

darcs-hash:20090128180900-db55f-6d1e1516223914b7721bc5febde8c2d0f6d6b96b.gz
parent 64525124
......@@ -394,7 +394,7 @@ gboolean su_source_prepare(GSource *gs, gint *return_tout)
now.tv_sec = gtimeval.tv_sec + 2208988800UL;
now.tv_usec = gtimeval.tv_usec;
tout = su_timer_next_expires(self->sup_base->sup_timers, now);
tout = su_timer_next_expires(&self->sup_base->sup_timers, now);
*return_tout = (tout < 0 || tout > (su_duration_t)G_MAXINT)?
-1 : (gint)tout;
......
......@@ -166,7 +166,7 @@ SOFIAPUBFUN su_port_t *su_port_create(void)
/* Extension from >= 1.12.5 */
SOFIAPUBFUN void su_msg_delivery_report(su_msg_r msg);
SOFIAPUBFUN su_duration_t su_timer_next_expires(su_timer_t const * t,
SOFIAPUBFUN su_duration_t su_timer_next_expires(su_timer_queue_t const *timers,
su_time_t now);
SOFIAPUBFUN su_root_t *su_root_create_with_port(su_root_magic_t *magic,
su_port_t *port)
......
......@@ -581,25 +581,22 @@ int su_timer_expire(su_timer_queue_t * const timers,
/** Calculate duration in milliseconds until next timer expires. */
su_duration_t su_timer_next_expires(su_timer_t const * t, su_time_t now)
su_duration_t su_timer_next_expires(su_timer_queue_t const *timers,
su_time_t now)
{
su_timer_queue_t *timers;
su_duration_t tout;
if (!t)
return SU_DURATION_MAX;
su_duration_t next = SU_DURATION_MAX;
timers = su_task_timers(t->sut_task);
su_timer_t const *t;
t = timers ? timers_get(timers[0], 1) : NULL;
t = timers ? timers_get(timers[0], 1) : NULL;
if (!t)
return SU_DURATION_MAX;
tout = su_duration(t->sut_when, now);
if (t) {
next = su_duration(t->sut_when, now);
if (next < 0)
next = 0;
}
return tout > 0 ? tout : 0 ;
return next;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment