Fix #222: SIPE crashes when groupchat session expires (VI)
authorStefan Becker <chemobejk@gmail.com>
Wed, 4 Dec 2013 12:23:05 +0000 (4 14:23 +0200)
committerStefan Becker <chemobejk@gmail.com>
Thu, 5 Dec 2013 20:48:42 +0000 (5 22:48 +0200)
As UPDATE now supports a callback, so it makes more sense to restart the
update timer in the callback.

(cherry picked from commit eda19ad695860d6b1d8d161ef96063182bdde060)

src/core/sipe-groupchat.c

index 20e50a6..74d22e7 100644 (file)
@@ -363,16 +363,26 @@ static gchar *generate_chanid_node(const gchar *uri, guint key)
 }
 
 /* TransCallback */
+static void groupchat_update_cb(struct sipe_core_private *sipe_private,
+                               gpointer data);
 static gboolean groupchat_expired_session_response(struct sipe_core_private *sipe_private,
                                                   struct sipmsg *msg,
                                                   SIPE_UNUSED_PARAMETER struct transaction *trans)
 {
+       struct sipe_groupchat *groupchat = sipe_private->groupchat;
+
        /* 481 Call Leg Does Not Exist -> server dropped session */
        if (msg->response == 481) {
-               struct sipe_groupchat *groupchat = sipe_private->groupchat;
                groupchat->session = NULL;
                groupchat->connected = FALSE;
                sipe_groupchat_init(sipe_private);
+       } else {
+               sipe_schedule_seconds(sipe_private,
+                                     "<+groupchat-expires>",
+                                     NULL,
+                                     groupchat->expires,
+                                     groupchat_update_cb,
+                                     NULL);
        }
 
        return(TRUE);
@@ -388,17 +398,10 @@ static void groupchat_update_cb(struct sipe_core_private *sipe_private,
                struct sip_dialog *dialog = sipe_dialog_find(groupchat->session,
                                                             groupchat->session->with);
 
-               if (dialog) {
+               if (dialog)
                        sip_transport_update(sipe_private,
                                             dialog,
                                             groupchat_expired_session_response);
-                       sipe_schedule_seconds(sipe_private,
-                                             "<+groupchat-expires>",
-                                             NULL,
-                                             groupchat->expires,
-                                             groupchat_update_cb,
-                                             NULL);
-               }
        }
 }