aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-12-24 19:36:59 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-12-24 19:36:59 +0000
commitf2c0963af6cc28285969b820dd1b1e669e981885 (patch)
tree1ea80ae05c39aaca48f914e29a10d69e88e60c20
parent6c055001f00785598971e5afa5f43bff68c1c77d (diff)
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) git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@94767 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--main/channel.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/main/channel.c b/main/channel.c
index d6c22cd74..c644dbe42 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -831,22 +831,6 @@ struct ast_channel *ast_channel_alloc(int needqueue, int state, const char *cid_
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? */
@@ -893,6 +877,25 @@ struct ast_channel *ast_channel_alloc(int needqueue, int state, const char *cid_
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;
}