[asterisk-commits] sgriepentrog: trunk r418962 - in /trunk: ./ channels/chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jul 18 12:42:47 CDT 2014


Author: sgriepentrog
Date: Fri Jul 18 12:42:41 2014
New Revision: 418962

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=418962
Log:
media formats: fix ref leak of peer for mwi subscription

Holding a reference to the peer during mwi subscriptions
resulted in a circular reference because the final event
message would not be sent until destruction of the peer.

Instead, pass the name of the peer to the event callback
so that it can fail gracefully after the peer has gone.

ASTERISK-23959
Review: https://reviewboard.asterisk.org/r/3754/
........

Merged revisions 418636 from http://svn.asterisk.org/svn/asterisk/branches/12

Modified:
    trunk/   (props changed)
    trunk/channels/chan_sip.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-12-merged' - no diff available.

Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=418962&r1=418961&r2=418962
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Fri Jul 18 12:42:41 2014
@@ -16753,14 +16753,18 @@
 /*! \brief Receive MWI events that we have subscribed to */
 static void mwi_event_cb(void *userdata, struct stasis_subscription *sub, struct stasis_message *msg)
 {
-	struct sip_peer *peer = userdata;
+	char *peer_name = userdata;
+	struct sip_peer *peer = sip_find_peer(peer_name, NULL, TRUE, FINDALLDEVICES, FALSE, 0);
+
 	if (stasis_subscription_final_message(sub, msg)) {
-		ao2_cleanup(peer);
+		ast_assert(peer == NULL);
+		ast_free(peer_name);
 		return;
 	}
-	if (ast_mwi_state_type() == stasis_message_type(msg)) {
+	if (peer && ast_mwi_state_type() == stasis_message_type(msg)) {
 		sip_send_mwi_to_peer(peer, 0);
 	}
+	ao2_cleanup(peer);
 }
 
 static void network_change_stasis_subscribe(void)
@@ -27293,8 +27297,11 @@
 
 		mailbox_specific_topic = ast_mwi_topic(mailbox->id);
 		if (mailbox_specific_topic) {
-			ao2_ref(peer, +1);
-			mailbox->event_sub = stasis_subscribe(mailbox_specific_topic, mwi_event_cb, peer);
+			char *peer_name = ast_strdup(peer->name);
+			if (!peer_name) {
+				return;
+			}
+			mailbox->event_sub = stasis_subscribe(mailbox_specific_topic, mwi_event_cb, peer_name);
 		}
 	}
 }




More information about the asterisk-commits mailing list