[asterisk-commits] tilghman: branch 1.4 r94767 - /branches/1.4/main/channel.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Dec 24 13:36:59 CST 2007


Author: tilghman
Date: Mon Dec 24 13:36:59 2007
New Revision: 94767

URL: http://svn.digium.com/view/asterisk?view=rev&rev=94767
Log:
Race: we need to wait to queue a NewChannel event until after the channel is
inserted into the channel list.  The reason is because some manager users
immediately queue requests from the channel when they see that event and are
confused when Asterisk reports no such channel. (Closes issue #11632)

Modified:
    branches/1.4/main/channel.c

Modified: branches/1.4/main/channel.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/channel.c?view=diff&rev=94767&r1=94766&r2=94767
==============================================================================
--- branches/1.4/main/channel.c (original)
+++ branches/1.4/main/channel.c Mon Dec 24 13:36:59 2007
@@ -831,22 +831,6 @@
 		ast_string_field_build_va(tmp, name, name_fmt, ap1, ap2);
 		va_end(ap1);
 		va_end(ap2);
-
-		/* and now, since the channel structure is built, and has its name, let's call the
-		 * manager event generator with this Newchannel event. This is the proper and correct
-		 * place to make this call, but you sure do have to pass a lot of data into this func
-		 * to do it here!
-		 */
-		manager_event(EVENT_FLAG_CALL, "Newchannel",
-			      "Channel: %s\r\n"
-			      "State: %s\r\n"
-			      "CallerIDNum: %s\r\n"
-			      "CallerIDName: %s\r\n"
-			      "Uniqueid: %s\r\n",
-			      tmp->name, ast_state2str(state),
-			      S_OR(cid_num, "<unknown>"),
-			      S_OR(cid_name, "<unknown>"),
-			      tmp->uniqueid);
 	}
 
 	/* Reminder for the future: under what conditions do we NOT want to track cdrs on channels? */
@@ -892,6 +876,25 @@
 	AST_LIST_LOCK(&channels);
 	AST_LIST_INSERT_HEAD(&channels, tmp, chan_list);
 	AST_LIST_UNLOCK(&channels);
+
+	/*\!note
+	 * and now, since the channel structure is built, and has its name, let's
+	 * call the manager event generator with this Newchannel event. This is the
+	 * proper and correct place to make this call, but you sure do have to pass
+	 * a lot of data into this func to do it here!
+	 */
+	if (!ast_strlen_zero(name_fmt)) {
+		manager_event(EVENT_FLAG_CALL, "Newchannel",
+		      "Channel: %s\r\n"
+		      "State: %s\r\n"
+		      "CallerIDNum: %s\r\n"
+		      "CallerIDName: %s\r\n"
+		      "Uniqueid: %s\r\n",
+		      tmp->name, ast_state2str(state),
+		      S_OR(cid_num, "<unknown>"),
+		      S_OR(cid_name, "<unknown>"),
+		      tmp->uniqueid);
+	}
 
 	return tmp;
 }




More information about the asterisk-commits mailing list