[asterisk-commits] rmudgett: trunk r320820 - in /trunk: ./ include/asterisk/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed May 25 11:50:49 CDT 2011


Author: rmudgett
Date: Wed May 25 11:50:38 2011
New Revision: 320820

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=320820
Log:
Merged revisions 320796 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.8

........
  r320796 | rmudgett | 2011-05-25 11:23:11 -0500 (Wed, 25 May 2011) | 17 lines
  
  Give zombies a safe channel driver to use.
  
  Recent crashes from zombie channels suggests that they need a safe home to
  goto.  When a masquerade happens, the physical part of the zombie channel
  is hungup.  The hangup normally sets the channel private pointer to NULL.
  If someone then blindly does a callback to the channel driver, a crash is
  likely because the private pointer is NULL.
  
  The masquerade now sets the channel technology of zombie channels to the
  kill channel driver.
  
  Related to the following issues:
  (issue #19116)
  (issue #19310)
  
  Review: https://reviewboard.asterisk.org/r/1224/
........

Modified:
    trunk/   (props changed)
    trunk/include/asterisk/channel.h
    trunk/main/channel.c
    trunk/main/features.c
    trunk/main/format_cap.c

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

Modified: trunk/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/channel.h?view=diff&rev=320820&r1=320819&r2=320820
==============================================================================
--- trunk/include/asterisk/channel.h (original)
+++ trunk/include/asterisk/channel.h Wed May 25 11:50:38 2011
@@ -632,6 +632,9 @@
 	 */
 	int (* cc_callback)(struct ast_channel *inbound, const char *dest, ast_cc_callback_fn callback);
 };
+
+/*! Kill the channel channel driver technology descriptor. */
+extern const struct ast_channel_tech ast_kill_tech;
 
 struct ast_epoll_data;
 

Modified: trunk/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/channel.c?view=diff&rev=320820&r1=320819&r2=320820
==============================================================================
--- trunk/main/channel.c (original)
+++ trunk/main/channel.c Wed May 25 11:50:38 2011
@@ -610,6 +610,55 @@
 static struct ast_cli_entry cli_channel[] = {
 	AST_CLI_DEFINE(handle_cli_core_show_channeltypes, "List available channel types"),
 	AST_CLI_DEFINE(handle_cli_core_show_channeltype,  "Give more details on that channel type")
+};
+
+static struct ast_frame *kill_read(struct ast_channel *chan)
+{
+	/* Hangup channel. */
+	return NULL;
+}
+
+static struct ast_frame *kill_exception(struct ast_channel *chan)
+{
+	/* Hangup channel. */
+	return NULL;
+}
+
+static int kill_write(struct ast_channel *chan, struct ast_frame *frame)
+{
+	/* Hangup channel. */
+	return -1;
+}
+
+static int kill_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
+{
+	/* No problem fixing up the channel. */
+	return 0;
+}
+
+static int kill_hangup(struct ast_channel *chan)
+{
+	chan->tech_pvt = NULL;
+	return 0;
+}
+
+/*!
+ * \brief Kill the channel channel driver technology descriptor.
+ *
+ * \details
+ * The purpose of this channel technology is to encourage the
+ * channel to hangup as quickly as possible.
+ *
+ * \note Used by DTMF atxfer and zombie channels.
+ */
+const struct ast_channel_tech ast_kill_tech = {
+	.type = "Kill",
+	.description = "Kill channel (should not see this)",
+	.read = kill_read,
+	.exception = kill_exception,
+	.write = kill_write,
+	.fixup = kill_fixup,
+	.hangup = kill_hangup,
 };
 
 #ifdef CHANNEL_TRACE
@@ -6613,6 +6662,12 @@
 		goto done;
 	}
 
+	/*
+	 * We just hung up the physical side of the channel.  Set the
+	 * new zombie to use the kill channel driver for safety.
+	 */
+	clonechan->tech = &ast_kill_tech;
+
 	/* Mangle the name of the clone channel */
 	snprintf(zombn, sizeof(zombn), "%s<ZOMBIE>", orig); /* quick, hide the brains! */
 	__ast_change_name_nolink(clonechan, zombn);

Modified: trunk/main/features.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/features.c?view=diff&rev=320820&r1=320819&r2=320820
==============================================================================
--- trunk/main/features.c (original)
+++ trunk/main/features.c Wed May 25 11:50:38 2011
@@ -478,58 +478,15 @@
 };
 
 #if defined(ATXFER_NULL_TECH)
-static struct ast_frame *null_read(struct ast_channel *chan)
-{
-	/* Hangup channel. */
-	return NULL;
-}
-
-static struct ast_frame *null_exception(struct ast_channel *chan)
-{
-	/* Hangup channel. */
-	return NULL;
-}
-
-static int null_write(struct ast_channel *chan, struct ast_frame *frame)
-{
-	/* Hangup channel. */
-	return -1;
-}
-
-static int null_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
-{
-	/* No problem fixing up the channel. */
-	return 0;
-}
-
-static int null_hangup(struct ast_channel *chan)
-{
-	chan->tech_pvt = NULL;
-	return 0;
-}
-
-static const struct ast_channel_tech null_tech = {
-	.type = "NULL",
-	.description = "NULL channel driver for atxfer",
-	.capabilities = -1,
-	.read = null_read,
-	.exception = null_exception,
-	.write = null_write,
-	.fixup = null_fixup,
-	.hangup = null_hangup,
-};
-#endif	/* defined(ATXFER_NULL_TECH) */
-
-#if defined(ATXFER_NULL_TECH)
 /*!
  * \internal
- * \brief Set the channel technology to the NULL technology.
+ * \brief Set the channel technology to the kill technology.
  *
  * \param chan Channel to change technology.
  *
  * \return Nothing
  */
-static void set_null_chan_tech(struct ast_channel *chan)
+static void set_kill_chan_tech(struct ast_channel *chan)
 {
 	int idx;
 
@@ -546,8 +503,8 @@
 		chan->tech_pvt = NULL;
 	}
 
-	/* Install the NULL technology and wake up anyone waiting on it. */
-	chan->tech = &null_tech;
+	/* Install the kill technology and wake up anyone waiting on it. */
+	chan->tech = &ast_kill_tech;
 	for (idx = 0; idx < AST_MAX_FDS; ++idx) {
 		switch (idx) {
 		case AST_ALERT_FD:
@@ -3146,7 +3103,7 @@
 				 * Get rid of caller's physical technology so it is free for
 				 * other calls.
 				 */
-				set_null_chan_tech(caller);
+				set_kill_chan_tech(caller);
 #endif	/* defined(ATXFER_NULL_TECH) */
 			} else {
 				/* caller is not hungup so monitor it. */

Modified: trunk/main/format_cap.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/format_cap.c?view=diff&rev=320820&r1=320819&r2=320820
==============================================================================
--- trunk/main/format_cap.c (original)
+++ trunk/main/format_cap.c Wed May 25 11:50:38 2011
@@ -307,8 +307,11 @@
 {
 	struct ast_format *f;
 	struct ast_format_cap *tmp_cap = (struct ast_format_cap *) cap;
+
+	if (!tmp_cap) {
+		return 0;
+	}
 	f = ao2_find(tmp_cap->formats, (struct ast_format *) format, OBJ_POINTER | tmp_cap->nolock);
-
 	if (f) {
 		ao2_ref(f, -1);
 		return 1;




More information about the asterisk-commits mailing list