From: Stefan Becker Date: Mon, 25 Nov 2013 13:47:02 +0000 (+0200) Subject: Fix #222: SIPE crashes when groupchat session expires (IV) X-Git-Tag: 1.17.2~2 X-Git-Url: https://repo.or.cz/w/siplcs.git/commitdiff_plain/be3e3561712c4657aab3a8a6b3e730245ab4d1fd Fix #222: SIPE crashes when groupchat session expires (IV) 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) --- diff --git a/src/core/sip-transport.c b/src/core/sip-transport.c index 8410afb2..15c10e59 100644 --- a/src/core/sip-transport.c +++ b/src/core/sip-transport.c @@ -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, diff --git a/src/core/sip-transport.h b/src/core/sip-transport.h index 99645436..a9c01a3c 100644 --- a/src/core/sip-transport.h +++ b/src/core/sip-transport.h @@ -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); diff --git a/src/core/sipe-groupchat.c b/src/core/sipe-groupchat.c index e1732145..f90909e5 100644 --- a/src/core/sipe-groupchat.c +++ b/src/core/sipe-groupchat.c @@ -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; }