From cf1f74fbc33e8a90d121793cb4aeeb7dca651c6b Mon Sep 17 00:00:00 2001 From: Michael Jerris <mike@jerris.com> Date: Wed, 11 Feb 2009 17:20:26 +0000 Subject: [PATCH] Wed Jan 28 12:31:06 CST 2009 Mikhail Zabaluev <mikhail.zabaluev@nokia.com> * su-glib/su_source.c: improved the deferrable timeout calculation git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11860 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- .../libsofia-sip-ua-glib/su-glib/su_source.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/libs/sofia-sip/libsofia-sip-ua-glib/su-glib/su_source.c b/libs/sofia-sip/libsofia-sip-ua-glib/su-glib/su_source.c index 646ae530a5..788f375fd2 100644 --- a/libs/sofia-sip/libsofia-sip-ua-glib/su-glib/su_source.c +++ b/libs/sofia-sip/libsofia-sip-ua-glib/su-glib/su_source.c @@ -386,7 +386,7 @@ gboolean su_source_prepare(GSource *gs, gint *return_tout) return TRUE; } - if (self->sup_base->sup_timers) { + if (self->sup_base->sup_timers || self->sup_base->sup_deferrable) { su_time_t now; GTimeVal gtimeval; @@ -395,10 +395,18 @@ gboolean su_source_prepare(GSource *gs, gint *return_tout) now.tv_usec = gtimeval.tv_usec; tout = su_timer_next_expires(&self->sup_base->sup_timers, now); - } - if (self->sup_base->sup_deferrable) { - if (tout > self->sup_base->sup_max_defer) - tout = self->sup_base->sup_max_defer; + + if (self->sup_base->sup_deferrable) { + su_duration_t tout_defer; + + tout_defer = su_timer_next_expires(&self->sup_base->sup_deferrable, now); + + if (tout_defer < self->sup_base->sup_max_defer) + tout_defer = self->sup_base->sup_max_defer; + + if (tout > tout_defer) + tout = tout_defer; + } } *return_tout = (tout >= 0 && tout <= (su_duration_t)G_MAXINT)?