[asterisk-commits] russell: branch 1.6.0 r108585 - in /branches/1.6.0: ./ apps/ include/asterisk...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Mar 13 16:41:14 CDT 2008


Author: russell
Date: Thu Mar 13 16:41:14 2008
New Revision: 108585

URL: http://svn.digium.com/view/asterisk?view=rev&rev=108585
Log:
Merged revisions 108584 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
r108584 | russell | 2008-03-13 16:40:43 -0500 (Thu, 13 Mar 2008) | 19 lines

Merged revisions 108583 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r108583 | russell | 2008-03-13 16:38:16 -0500 (Thu, 13 Mar 2008) | 11 lines

Fix another issue that was causing crashes in chanspy.  This introduces a new
datastore callback, called chan_fixup().  The concept is exactly like the
fixup callback that is used in the channel technology interface.  This callback
gets called when the owning channel changes due to a masquerade.  Before this
was introduced, if a masquerade happened on a channel being spyed on, the
channel pointer in the datastore became invalid.

(closes issue #12187)
(reported by, and lots of testing from atis)
(props to file for the help with ideas)

........

................

Modified:
    branches/1.6.0/   (props changed)
    branches/1.6.0/apps/app_chanspy.c
    branches/1.6.0/include/asterisk/channel.h
    branches/1.6.0/main/channel.c

Propchange: branches/1.6.0/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.0/apps/app_chanspy.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/apps/app_chanspy.c?view=diff&rev=108585&r1=108584&r2=108585
==============================================================================
--- branches/1.6.0/apps/app_chanspy.c (original)
+++ branches/1.6.0/apps/app_chanspy.c Thu Mar 13 16:41:14 2008
@@ -427,9 +427,19 @@
 	ast_mutex_unlock(&chanspy_ds->lock);
 }
 
+static void chanspy_ds_chan_fixup(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan)
+{
+	struct chanspy_ds *chanspy_ds = data;
+	
+	ast_mutex_lock(&chanspy_ds->lock);
+	chanspy_ds->chan = new_chan;
+	ast_mutex_unlock(&chanspy_ds->lock);
+}
+
 static const struct ast_datastore_info chanspy_ds_info = {
 	.type = "chanspy",
 	.destroy = chanspy_ds_destroy,
+	.chan_fixup = chanspy_ds_chan_fixup,
 };
 
 static struct chanspy_ds *chanspy_ds_free(struct chanspy_ds *chanspy_ds)

Modified: branches/1.6.0/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/include/asterisk/channel.h?view=diff&rev=108585&r1=108584&r2=108585
==============================================================================
--- branches/1.6.0/include/asterisk/channel.h (original)
+++ branches/1.6.0/include/asterisk/channel.h Thu Mar 13 16:41:14 2008
@@ -191,6 +191,21 @@
 	const char *type;		/*!< Type of data store */
 	void *(*duplicate)(void *data);	/*!< Duplicate item data (used for inheritance) */
 	void (*destroy)(void *data);	/*!< Destroy function */
+	/*!
+	 * \brief Fix up channel references
+	 *
+	 * \arg data The datastore data
+	 * \arg old_chan The old channel owning the datastore
+	 * \arg new_chan The new channel owning the datastore
+	 *
+	 * This is exactly like the fixup callback of the channel technology interface.
+	 * It allows a datastore to fix any pointers it saved to the owning channel
+	 * in case that the owning channel has changed.  Generally, this would happen
+	 * when the datastore is set to be inherited, and a masquerade occurs.
+	 *
+	 * \return nothing.
+	 */
+	void (*chan_fixup)(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan);
 };
 
 /*! \brief Structure for a channel data store */

Modified: branches/1.6.0/main/channel.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/main/channel.c?view=diff&rev=108585&r1=108584&r2=108585
==============================================================================
--- branches/1.6.0/main/channel.c (original)
+++ branches/1.6.0/main/channel.c Thu Mar 13 16:41:14 2008
@@ -3878,8 +3878,14 @@
 	ast_app_group_update(clone, original);
 
 	/* Move data stores over */
-	if (AST_LIST_FIRST(&clone->datastores))
+	if (AST_LIST_FIRST(&clone->datastores)) {
+		struct ast_datastore *ds;
 		AST_LIST_APPEND_LIST(&original->datastores, &clone->datastores, entry);
+		AST_LIST_TRAVERSE(&original->datastores, ds, entry) {
+			if (ds->info->chan_fixup)
+				ds->info->chan_fixup(ds->data, clone, original);
+		}
+	}
 
 	clone_variables(original, clone);
 	/* Presense of ADSI capable CPE follows clone */




More information about the asterisk-commits mailing list