Fix #222: SIPE crashes when groupchat session expires (IV)
authorStefan Becker <chemobejk@gmail.com>
Mon, 25 Nov 2013 13:47:02 +0000 (25 15:47 +0200)
committerStefan Becker <chemobejk@gmail.com>
Mon, 25 Nov 2013 14:00:20 +0000 (25 16:00 +0200)
Add a callback to sip_transport_update(). We use it to check for an
expired session and re-initialize the groupchat session again.

(cherry picked from commit 6c596cb6def04f4d2758423c2ee1cbd59815626c)

src/core/sip-transport.c
src/core/sip-transport.h
src/core/sipe-groupchat.c

index 8410afb..15c10e5 100644 (file)
@@ -873,9 +873,17 @@ void sip_transport_subscribe(struct sipe_core_private *sipe_private,
 }
 
 void sip_transport_update(struct sipe_core_private *sipe_private,
-                         struct sip_dialog *dialog)
+                         struct sip_dialog *dialog,
+                         TransCallback callback)
 {
-       sip_transport_simple_request(sipe_private, "UPDATE", dialog);
+       sip_transport_request(sipe_private,
+                             "UPDATE",
+                             dialog->with,
+                             dialog->with,
+                             NULL,
+                             NULL,
+                             dialog,
+                             callback);
 }
 
 static const gchar *get_auth_header(struct sipe_core_private *sipe_private,
index 9964543..a9c01a3 100644 (file)
@@ -106,7 +106,8 @@ void sip_transport_subscribe(struct sipe_core_private *sipe_private,
                             struct sip_dialog *dialog,
                             TransCallback callback);
 void sip_transport_update(struct sipe_core_private *sipe_private,
-                         struct sip_dialog *dialog);
+                         struct sip_dialog *dialog,
+                         TransCallback callback);
 
 /* Misc. SIP transport stuff */
 guint sip_transport_port(struct sipe_core_private *sipe_private);
index e173214..f90909e 100644 (file)
@@ -362,6 +362,22 @@ static gchar *generate_chanid_node(const gchar *uri, guint key)
        return chanid;
 }
 
+/* TransCallback */
+static gboolean groupchat_expired_session_response(struct sipe_core_private *sipe_private,
+                                                  struct sipmsg *msg,
+                                                  SIPE_UNUSED_PARAMETER struct transaction *trans)
+{
+       /* 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);
+       }
+
+       return(TRUE);
+}
+
 /* sipe_schedule_action */
 static void groupchat_update_cb(struct sipe_core_private *sipe_private,
                                SIPE_UNUSED_PARAMETER gpointer data)
@@ -371,7 +387,9 @@ static void groupchat_update_cb(struct sipe_core_private *sipe_private,
                                                     groupchat->session->with);
 
        if (dialog)
-               sip_transport_update(sipe_private, dialog);
+               sip_transport_update(sipe_private,
+                                    dialog,
+                                    groupchat_expired_session_response);
        sipe_schedule_seconds(sipe_private,
                              "<+groupchat-expires>",
                              NULL,
@@ -496,13 +514,7 @@ static gboolean chatserver_command_response(struct sipe_core_private *sipe_priva
                                                        chat_session,
                                                        gmsg->content);
 
-               /* 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);
-               }
+               groupchat_expired_session_response(sipe_private, msg, trans);
        }
        return TRUE;
 }