[asterisk-commits] file: trunk r403543 - in /trunk: ./ main/endpoints.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Dec 9 12:32:04 CST 2013


Author: file
Date: Mon Dec  9 12:32:02 2013
New Revision: 403543

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=403543
Log:
endpoints: Keep a reference to channel ids when creating snapshot.

The snapshot process for endpoints uses the channel ids present
on the endpoint itself. Without keeping a reference it was possible
for the strings to be freed underneath any consumer of an endpoint
snapshot.

A reference is now held by the snapshot to the channel ids and
released when the snapshot is destroyed.

(issue ASTERISK-22801)
Reported by: Matt Jordan
........

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

Modified:
    trunk/   (props changed)
    trunk/main/endpoints.c

Propchange: trunk/
------------------------------------------------------------------------------
--- branch-12-merged (original)
+++ branch-12-merged Mon Dec  9 12:32:02 2013
@@ -1,1 +1,1 @@
-/branches/12:1-398558,398560-398577,398579-399305,399307-401390,401392-403290,403292-403398,403435,403458,403510,403527
+/branches/12:1-398558,398560-398577,398579-399305,399307-401390,401392-403290,403292-403398,403435,403458,403510,403527,403542

Modified: trunk/main/endpoints.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/endpoints.c?view=diff&rev=403543&r1=403542&r2=403543
==============================================================================
--- trunk/main/endpoints.c (original)
+++ trunk/main/endpoints.c Mon Dec  9 12:32:02 2013
@@ -388,8 +388,14 @@
 static void endpoint_snapshot_dtor(void *obj)
 {
 	struct ast_endpoint_snapshot *snapshot = obj;
+	int channel;
 
 	ast_assert(snapshot != NULL);
+
+	for (channel = 0; channel < snapshot->num_channels; channel++) {
+		ao2_ref(snapshot->channel_ids[channel], -1);
+	}
+
 	ast_string_field_free_memory(snapshot);
 }
 
@@ -422,8 +428,8 @@
 
 	i = ao2_iterator_init(endpoint->channel_ids, 0);
 	while ((obj = ao2_iterator_next(&i))) {
-		RAII_VAR(char *, channel_id, obj, ao2_cleanup);
-		snapshot->channel_ids[snapshot->num_channels++] = channel_id;
+		/* The reference is kept so the channel id does not go away until the snapshot is gone */
+		snapshot->channel_ids[snapshot->num_channels++] = obj;
 	}
 	ao2_iterator_destroy(&i);
 




More information about the asterisk-commits mailing list