From e202543c7696b941f88e07e5f5781d72558827ed Mon Sep 17 00:00:00 2001
From: Michael Jerris <mike@jerris.com>
Date: Wed, 11 Feb 2009 17:20:59 +0000
Subject: [PATCH] Wed Jan 28 12:32:01 CST 2009  Mikhail Zabaluev
 <mikhail.zabaluev@nokia.com>   * nua/outbound.c: calculate the keepalive
 timer interval with regard to the maximum defer interval

  The point is not to miss the keepalive deadlines.



git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11861 d0543943-73ff-0310-b7d9-9358b9ac24b2
---
 libs/sofia-sip/.update                        | 2 +-
 libs/sofia-sip/libsofia-sip-ua/nua/outbound.c | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/libs/sofia-sip/.update b/libs/sofia-sip/.update
index fbeadfbc8c..2b50a09ed9 100644
--- a/libs/sofia-sip/.update
+++ b/libs/sofia-sip/.update
@@ -1 +1 @@
-Wed Feb 11 11:19:42 CST 2009
+Wed Feb 11 11:20:46 CST 2009
diff --git a/libs/sofia-sip/libsofia-sip-ua/nua/outbound.c b/libs/sofia-sip/libsofia-sip-ua/nua/outbound.c
index 1e518f9fc5..3141629749 100644
--- a/libs/sofia-sip/libsofia-sip-ua/nua/outbound.c
+++ b/libs/sofia-sip/libsofia-sip-ua/nua/outbound.c
@@ -685,8 +685,16 @@ void outbound_start_keepalive(outbound_t *ob,
     su_timer_destroy(ob->ob_keepalive.timer), ob->ob_keepalive.timer = NULL;
 
   if (interval) {
+    su_duration_t max_defer;
+
+    max_defer = su_root_get_max_defer(ob->ob_root);
+    if ((su_duration_t)interval >= max_defer) {
+      interval -= max_defer - 100;
+    }
+
     ob->ob_keepalive.timer =
       su_timer_create(su_root_task(ob->ob_root), interval);
+
     su_timer_deferrable(ob->ob_keepalive.timer, 1);
   }