[telepathy-sofiasip/master] Initialize heartbeat only when successfully registered

Mikhail Zabaluev mikhail.zabaluev at nokia.com
Tue Sep 15 08:32:12 PDT 2009


Some time may pass between the first registration request and
the final successful response, and maybe we shouldn't commit
the resources in failure cases at all.
---
 src/sip-connection.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/sip-connection.c b/src/sip-connection.c
index 29af4c4..6c35ef9 100644
--- a/src/sip-connection.c
+++ b/src/sip-connection.c
@@ -727,6 +727,7 @@ tpsip_connection_nua_r_register_cb (TpsipConnection     *self,
                                     tagi_t               tags[],
                                     gpointer             foo)
 {
+  TpBaseConnection *base = (TpBaseConnection *) self;
   TpConnectionStatus conn_status = TP_CONNECTION_STATUS_DISCONNECTED;
   TpConnectionStatusReason reason = 0;
 
@@ -755,14 +756,18 @@ tpsip_connection_nua_r_register_cb (TpsipConnection     *self,
         }
       else /* if (ev->status == 200) */
         {
+          if (base->status != TP_CONNECTION_STATUS_CONNECTING)
+            return TRUE;
+
           DEBUG("succesfully registered to the network");
           conn_status = TP_CONNECTION_STATUS_CONNECTED;
           reason = TP_CONNECTION_STATUS_REASON_REQUESTED;
+
+          tpsip_conn_heartbeat_init (self);
         }
     }
 
-  tp_base_connection_change_status ((TpBaseConnection *) self,
-                                    conn_status, reason);
+  tp_base_connection_change_status (base, conn_status, reason);
 
   return TRUE;
 }
@@ -953,8 +958,6 @@ tpsip_connection_start_connecting (TpBaseConnection *base,
 
   nua_register (priv->register_op, TAG_NULL());
 
-  tpsip_conn_heartbeat_init (self);
-
   return TRUE;
 }
 
-- 
1.5.6.5




More information about the telepathy-commits mailing list