[asterisk-commits] mjordan: branch 12 r416211 - in /branches/12: apps/ include/asterisk/ main/ r...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Jun 13 13:16:45 CDT 2014
Author: mjordan
Date: Fri Jun 13 13:16:34 2014
New Revision: 416211
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=416211
Log:
stasis: Reduce creation of channel snapshots to improve performance
During some performance testing of Asterisk with AGI, ARI, and lots of Local
channels, we noticed that there's quite a hit in performance during channel
creation and releasing to the dialplan (ARI continue). After investigating
the performance spike that occurs during channel creation, we discovered
that we create a lot of channel snapshots that are technically unnecessary.
This includes creating snapshots during:
* AGI execution
* Returning objects for ARI commands
* During some Local channel operations
* During some dialling operations
* During variable setting
* During some bridging operations
And more.
This patch does the following:
- It removes a number of fields from channel snapshots. These fields were
rarely used, were expensive to have on the snapshot, and hurt performance.
This included formats, translation paths, Log Call ID, callgroup, pickup
group, and all channel variables. As a result, AMI Status,
"core show channel", "core show channelvar", and "pjsip show channel" were
modified to either hit the live channel or not show certain pieces of data.
While this is unfortunate, the performance gain from this patch is worth
the loss in behaviour.
- It adds a mechanism to publish a cached snapshot + blob. A large number of
publications were changed to use this, including:
- During Dial begin
- During Variable assignment (if no AMI variables are emitted - if AMI
variables are set, we have to make snapshots when a variable is changed)
- During channel pickup
- When a channel is put on hold/unhold
- When a DTMF digit is begun/ended
- When creating a bridge snapshot
- When an AOC event is raised
- During Local channel optimization/Local bridging
- When endpoint snapshots are generated
- All AGI events
- All ARI responses that return a channel
- Events in the AgentPool, MeetMe, and some in Queue
- Additionally, some extraneous channel snapshots were being made that were
unnecessary. These were removed.
- The result of ast_hashtab_hash_string is now cached in stasis_cache. This
reduces a large number of calls to ast_hashtab_hash_string, which reduced
the amount of time spent in this function in gprof by around 50%.
ASTERISK-23811 #close
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/3568/
Modified:
branches/12/apps/app_agent_pool.c
branches/12/apps/app_meetme.c
branches/12/apps/app_queue.c
branches/12/include/asterisk/channel.h
branches/12/include/asterisk/stasis_channels.h
branches/12/main/aoc.c
branches/12/main/bridge_channel.c
branches/12/main/cel.c
branches/12/main/channel.c
branches/12/main/channel_internal_api.c
branches/12/main/cli.c
branches/12/main/core_local.c
branches/12/main/dial.c
branches/12/main/endpoints.c
branches/12/main/manager.c
branches/12/main/pbx.c
branches/12/main/pickup.c
branches/12/main/stasis_bridges.c
branches/12/main/stasis_cache.c
branches/12/main/stasis_channels.c
branches/12/res/ari/resource_channels.c
branches/12/res/res_agi.c
branches/12/res/res_pjsip/pjsip_configuration.c
Modified: branches/12/apps/app_agent_pool.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/apps/app_agent_pool.c?view=diff&rev=416211&r1=416210&r2=416211
==============================================================================
--- branches/12/apps/app_agent_pool.c (original)
+++ branches/12/apps/app_agent_pool.c Fri Jun 13 13:16:34 2014
@@ -1442,7 +1442,7 @@
return;
}
- ast_channel_publish_blob(chan, ast_channel_agent_login_type(), blob);
+ ast_channel_publish_cached_blob(chan, ast_channel_agent_login_type(), blob);
}
static void send_agent_logoff(struct ast_channel *chan, const char *agent, long logintime)
@@ -1458,7 +1458,7 @@
return;
}
- ast_channel_publish_blob(chan, ast_channel_agent_logoff_type(), blob);
+ ast_channel_publish_cached_blob(chan, ast_channel_agent_logoff_type(), blob);
}
/*!
Modified: branches/12/apps/app_meetme.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/apps/app_meetme.c?view=diff&rev=416211&r1=416210&r2=416211
==============================================================================
--- branches/12/apps/app_meetme.c (original)
+++ branches/12/apps/app_meetme.c Fri Jun 13 13:16:34 2014
@@ -1379,9 +1379,7 @@
}
}
- ast_channel_lock(chan);
- msg = ast_channel_blob_create(chan, message_type, json_object);
- ast_channel_unlock(chan);
+ msg = ast_channel_blob_create_from_cache(ast_channel_uniqueid(chan), message_type, json_object);
if (!msg) {
return;
Modified: branches/12/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/apps/app_queue.c?view=diff&rev=416211&r1=416210&r2=416211
==============================================================================
--- branches/12/apps/app_queue.c (original)
+++ branches/12/apps/app_queue.c Fri Jun 13 13:16:34 2014
@@ -3510,9 +3510,7 @@
"Queue", q->name,
"Position", qe->pos,
"Count", q->count);
- ast_channel_lock(qe->chan);
- ast_channel_publish_blob(qe->chan, queue_caller_join_type(), blob);
- ast_channel_unlock(qe->chan);
+ ast_channel_publish_cached_blob(qe->chan, queue_caller_join_type(), blob);
ast_debug(1, "Queue '%s' Join, Channel '%s', Position '%d'\n", q->name, ast_channel_name(qe->chan), qe->pos );
}
ao2_unlock(q);
@@ -3791,9 +3789,7 @@
"Queue", q->name,
"Position", qe->pos,
"Count", q->count);
- ast_channel_lock(qe->chan);
- ast_channel_publish_blob(qe->chan, queue_caller_leave_type(), blob);
- ast_channel_unlock(qe->chan);
+ ast_channel_publish_cached_blob(qe->chan, queue_caller_leave_type(), blob);
ast_debug(1, "Queue '%s' Leave, Channel '%s'\n", q->name, ast_channel_name(qe->chan));
/* Take us out of the queue */
if (prev) {
@@ -4395,9 +4391,7 @@
qe->parent->callsabandoned++;
ao2_unlock(qe->parent);
- ast_channel_lock(qe->chan);
- ast_channel_publish_blob(qe->chan, queue_caller_abandon_type(), blob);
- ast_channel_unlock(qe->chan);
+ ast_channel_publish_cached_blob(qe->chan, queue_caller_abandon_type(), blob);
}
/*! \brief RNA == Ring No Answer. Common code that is executed when we try a queue member and they don't answer. */
Modified: branches/12/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/branches/12/include/asterisk/channel.h?view=diff&rev=416211&r1=416210&r2=416211
==============================================================================
--- branches/12/include/asterisk/channel.h (original)
+++ branches/12/include/asterisk/channel.h Fri Jun 13 13:16:34 2014
@@ -4190,6 +4190,15 @@
struct ast_flags *ast_channel_flags(struct ast_channel *chan);
/*!
+ * \since 12.4.0
+ * \brief Return whether or not any manager variables have been set
+ *
+ * \retval 0 if no manager variables are expected
+ * \retval 1 if manager variables are expected
+ */
+int ast_channel_has_manager_vars(void);
+
+/*!
* \since 12
* \brief Sets the variables to be stored in the \a manager_vars field of all
* snapshots.
Modified: branches/12/include/asterisk/stasis_channels.h
URL: http://svnview.digium.com/svn/asterisk/branches/12/include/asterisk/stasis_channels.h?view=diff&rev=416211&r1=416210&r2=416211
==============================================================================
--- branches/12/include/asterisk/stasis_channels.h (original)
+++ branches/12/include/asterisk/stasis_channels.h Fri Jun 13 13:16:34 2014
@@ -39,17 +39,16 @@
struct ast_channel_snapshot {
AST_DECLARE_STRING_FIELDS(
AST_STRING_FIELD(name); /*!< ASCII unique channel name */
- AST_STRING_FIELD(type); /*!< Type of channel technology */
- AST_STRING_FIELD(accountcode); /*!< Account code for billing */
- AST_STRING_FIELD(peeraccount); /*!< Peer account code for billing */
- AST_STRING_FIELD(userfield); /*!< Userfield for CEL billing */
AST_STRING_FIELD(uniqueid); /*!< Unique Channel Identifier */
AST_STRING_FIELD(linkedid); /*!< Linked Channel Identifier -- gets propagated by linkage */
- AST_STRING_FIELD(hangupsource); /*!< Who is responsible for hanging up this channel */
AST_STRING_FIELD(appl); /*!< Current application */
AST_STRING_FIELD(data); /*!< Data passed to current application */
AST_STRING_FIELD(context); /*!< Dialplan: Current extension context */
AST_STRING_FIELD(exten); /*!< Dialplan: Current extension number */
+ AST_STRING_FIELD(accountcode); /*!< Account code for billing */
+ AST_STRING_FIELD(peeraccount); /*!< Peer account code for billing */
+ AST_STRING_FIELD(userfield); /*!< Userfield for CEL billing */
+ AST_STRING_FIELD(hangupsource); /*!< Who is responsible for hanging up this channel */
AST_STRING_FIELD(caller_name); /*!< Caller ID Name */
AST_STRING_FIELD(caller_number); /*!< Caller ID Number */
AST_STRING_FIELD(caller_dnid); /*!< Dialed ID Number */
@@ -59,31 +58,20 @@
AST_STRING_FIELD(dialed_subaddr); /*!< Dialed subaddress */
AST_STRING_FIELD(connected_name); /*!< Connected Line Name */
AST_STRING_FIELD(connected_number); /*!< Connected Line Number */
- AST_STRING_FIELD(effective_name); /*!< Effective Connected Line Name */
- AST_STRING_FIELD(effective_number); /*!< Effective Connected Line Number */
AST_STRING_FIELD(language); /*!< The default spoken language for the channel */
AST_STRING_FIELD(bridgeid); /*!< Unique Bridge Identifier */
- AST_STRING_FIELD(nativeformats); /*!< Native formats on the channel */
- AST_STRING_FIELD(readformat); /*!< The current read format */
- AST_STRING_FIELD(writeformat); /*!< The current write format */
- AST_STRING_FIELD(writetrans); /*!< The current write translation path */
- AST_STRING_FIELD(readtrans); /*!< The current read translation path */
+ AST_STRING_FIELD(type); /*!< Type of channel technology */
);
- char callid[AST_CALLID_BUFFER_LENGTH]; /*!< Callid for the channel */
struct timeval creationtime; /*!< The time of channel creation */
- struct timeval hanguptime; /*!< When the channel should hang up */
enum ast_channel_state state; /*!< State of line */
int priority; /*!< Dialplan: Current extension priority */
int amaflags; /*!< AMA flags for billing */
int hangupcause; /*!< Why is the channel hanged up. See causes.h */
int caller_pres; /*!< Caller ID presentation. */
struct ast_flags flags; /*!< channel flags of AST_FLAG_ type */
- ast_group_t callgroup; /*!< Call group */
- ast_group_t pickupgroup; /*!< Pickup group */
struct ast_flags softhangup_flags; /*!< softhangup channel flags */
struct varshead *manager_vars; /*!< Variables to be appended to manager events */
- struct varshead *channel_vars; /*!< Variables set on the channel */
int tech_properties; /*!< Properties of the channel's technology */
};
@@ -321,6 +309,23 @@
struct ast_json *blob);
/*!
+ * \brief Publish a channel blob message using the latest snapshot from the cache
+ * \since 12.4.0
+ *
+ * \param chan Channel publishing the blob.
+ * \param type Type of stasis message.
+ * \param blob The blob being published. (NULL if no blob)
+ *
+ * \note As this only accesses the uniqueid and topic of the channel - neither of
+ * which should ever be changed on a channel anyhow - a channel does not have to
+ * be locked when calling this function.
+ *
+ * \return Nothing
+ */
+void ast_channel_publish_cached_blob(struct ast_channel *chan, struct stasis_message_type *type,
+ struct ast_json *blob);
+
+/*!
* \since 12
* \brief Set flag to indicate channel snapshot is being staged.
*
Modified: branches/12/main/aoc.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/aoc.c?view=diff&rev=416211&r1=416210&r2=416211
==============================================================================
--- branches/12/main/aoc.c (original)
+++ branches/12/main/aoc.c Fri Jun 13 13:16:34 2014
@@ -1871,7 +1871,7 @@
return 0;
}
- ast_channel_publish_blob(chan, msg_type, blob);
+ ast_channel_publish_cached_blob(chan, msg_type, blob);
return 0;
}
Modified: branches/12/main/bridge_channel.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/bridge_channel.c?view=diff&rev=416211&r1=416210&r2=416211
==============================================================================
--- branches/12/main/bridge_channel.c (original)
+++ branches/12/main/bridge_channel.c Fri Jun 13 13:16:34 2014
@@ -838,18 +838,16 @@
datalen = 0;
}
- ast_channel_lock(bridge_channel->chan);
- ast_channel_publish_blob(bridge_channel->chan, ast_channel_hold_type(), blob);
- ast_channel_unlock(bridge_channel->chan);
+ ast_channel_publish_cached_blob(bridge_channel->chan, ast_channel_hold_type(), blob);
+
return ast_bridge_channel_write_control_data(bridge_channel, AST_CONTROL_HOLD,
moh_class, datalen);
}
int ast_bridge_channel_write_unhold(struct ast_bridge_channel *bridge_channel)
{
- ast_channel_lock(bridge_channel->chan);
- ast_channel_publish_blob(bridge_channel->chan, ast_channel_unhold_type(), NULL);
- ast_channel_unlock(bridge_channel->chan);
+ ast_channel_publish_cached_blob(bridge_channel->chan, ast_channel_unhold_type(), NULL);
+
return ast_bridge_channel_write_control_data(bridge_channel, AST_CONTROL_UNHOLD, NULL, 0);
}
Modified: branches/12/main/cel.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/cel.c?view=diff&rev=416211&r1=416210&r2=416211
==============================================================================
--- branches/12/main/cel.c (original)
+++ branches/12/main/cel.c Fri Jun 13 13:16:34 2014
@@ -1798,9 +1798,7 @@
"event_type", event_type,
"event_details", blob);
- ast_channel_lock(chan);
- message = ast_channel_blob_create(chan, cel_generic_type(), cel_blob);
- ast_channel_unlock(chan);
+ message = ast_channel_blob_create_from_cache(ast_channel_uniqueid(chan), cel_generic_type(), cel_blob);
if (message) {
stasis_publish(ast_cel_topic(), message);
}
Modified: branches/12/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/channel.c?view=diff&rev=416211&r1=416210&r2=416211
==============================================================================
--- branches/12/main/channel.c (original)
+++ branches/12/main/channel.c Fri Jun 13 13:16:34 2014
@@ -1270,7 +1270,6 @@
struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_HOLD };
int res;
- ast_channel_lock(chan);
if (!ast_strlen_zero(musicclass)) {
f.data.ptr = (void *) musicclass;
f.datalen = strlen(musicclass) + 1;
@@ -1279,10 +1278,10 @@
"musicclass", musicclass);
}
- ast_channel_publish_blob(chan, ast_channel_hold_type(), blob);
+ ast_channel_publish_cached_blob(chan, ast_channel_hold_type(), blob);
res = ast_queue_frame(chan, &f);
- ast_channel_unlock(chan);
+
return res;
}
@@ -1291,11 +1290,10 @@
struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_UNHOLD };
int res;
- ast_channel_lock(chan);
- ast_channel_publish_blob(chan, ast_channel_unhold_type(), NULL);
+ ast_channel_publish_cached_blob(chan, ast_channel_unhold_type(), NULL);
res = ast_queue_frame(chan, &f);
- ast_channel_unlock(chan);
+
return res;
}
@@ -3639,7 +3637,7 @@
return;
}
- ast_channel_publish_blob(chan, ast_channel_dtmf_begin_type(), blob);
+ ast_channel_publish_cached_blob(chan, ast_channel_dtmf_begin_type(), blob);
}
static void send_dtmf_end_event(struct ast_channel *chan,
@@ -3656,7 +3654,7 @@
return;
}
- ast_channel_publish_blob(chan, ast_channel_dtmf_end_type(), blob);
+ ast_channel_publish_cached_blob(chan, ast_channel_dtmf_end_type(), blob);
}
static void ast_read_generator_actions(struct ast_channel *chan, struct ast_frame *f)
@@ -3988,7 +3986,6 @@
ast_frfree(f);
f = &ast_null_frame;
} else {
- /* Answer the CDR */
ast_setstate(chan, AST_STATE_UP);
}
} else if (f->subclass.integer == AST_CONTROL_READ_ACTION) {
@@ -5337,10 +5334,6 @@
generator_write_format_change(chan);
}
- ast_channel_lock(chan);
- ast_channel_publish_snapshot(chan);
- ast_channel_unlock(chan);
-
return 0;
}
@@ -5419,10 +5412,6 @@
if (direction && ast_channel_generatordata(chan)) {
generator_write_format_change(chan);
}
-
- ast_channel_lock(chan);
- ast_channel_publish_snapshot(chan);
- ast_channel_unlock(chan);
return res;
}
@@ -7419,6 +7408,17 @@
AST_RWLIST_UNLOCK(&channelvars);
}
+int ast_channel_has_manager_vars(void)
+{
+ int vars_present;
+
+ AST_RWLIST_RDLOCK(&channelvars);
+ vars_present = !AST_LIST_EMPTY(&channelvars);
+ AST_RWLIST_UNLOCK(&channelvars);
+
+ return vars_present;
+}
+
void ast_channel_set_manager_vars(size_t varc, char **vars)
{
size_t i;
@@ -7649,12 +7649,9 @@
{
struct ast_variable *cur;
- ast_channel_stage_snapshot(chan);
-
- for (cur = vars; cur; cur = cur->next)
+ for (cur = vars; cur; cur = cur->next) {
pbx_builtin_setvar_helper(chan, cur->name, cur->value);
-
- ast_channel_stage_snapshot_done(chan);
+ }
}
static void *silence_generator_alloc(struct ast_channel *chan, void *data)
Modified: branches/12/main/channel_internal_api.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/channel_internal_api.c?view=diff&rev=416211&r1=416210&r2=416211
==============================================================================
--- branches/12/main/channel_internal_api.c (original)
+++ branches/12/main/channel_internal_api.c Fri Jun 13 13:16:34 2014
@@ -943,9 +943,8 @@
ast_channel_name(chan),
call_identifier_to,
call_identifier_from);
-
- ast_channel_publish_snapshot(chan);
-}
+}
+
void ast_channel_state_set(struct ast_channel *chan, enum ast_channel_state value)
{
chan->state = value;
@@ -1073,7 +1072,6 @@
void ast_channel_whentohangup_set(struct ast_channel *chan, struct timeval *value)
{
chan->whentohangup = *value;
- ast_channel_publish_snapshot(chan);
}
void ast_channel_varshead_set(struct ast_channel *chan, struct varshead *value)
{
@@ -1131,7 +1129,6 @@
void ast_channel_callgroup_set(struct ast_channel *chan, ast_group_t value)
{
chan->callgroup = value;
- ast_channel_publish_snapshot(chan);
}
ast_group_t ast_channel_pickupgroup(const struct ast_channel *chan)
{
@@ -1140,7 +1137,6 @@
void ast_channel_pickupgroup_set(struct ast_channel *chan, ast_group_t value)
{
chan->pickupgroup = value;
- ast_channel_publish_snapshot(chan);
}
struct ast_namedgroups *ast_channel_named_callgroups(const struct ast_channel *chan)
{
Modified: branches/12/main/cli.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/cli.c?view=diff&rev=416211&r1=416210&r2=416211
==============================================================================
--- branches/12/main/cli.c (original)
+++ branches/12/main/cli.c Fri Jun 13 13:16:34 2014
@@ -1513,8 +1513,7 @@
static char *handle_showchan(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
- RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
- struct ast_channel_snapshot *snapshot;
+ struct ast_channel *chan;
struct timeval now;
char cdrtime[256];
struct ast_str *obuf;/*!< Buffer for CDR variables. */
@@ -1522,6 +1521,12 @@
long elapsed_seconds=0;
int hour=0, min=0, sec=0;
struct ast_var_t *var;
+ char nativeformats[256];
+ struct ast_str *write_transpath = ast_str_alloca(256);
+ struct ast_str *read_transpath = ast_str_alloca(256);
+ struct ast_bridge *bridge;
+ struct ast_callid *callid;
+ char callid_buf[32];
switch (cmd) {
case CLI_INIT:
@@ -1538,31 +1543,43 @@
return CLI_SHOWUSAGE;
}
- now = ast_tvnow();
-
- if (!(msg = stasis_cache_get(ast_channel_cache_by_name(), ast_channel_snapshot_type(), a->argv[3]))) {
- ast_cli(a->fd, "%s is not a known channel\n", a->argv[3]);
- return CLI_SUCCESS;
- }
- snapshot = stasis_message_data(msg);
-
obuf = ast_str_thread_get(&ast_str_thread_global_buf, 16);
if (!obuf) {
return CLI_FAILURE;
}
+
output = ast_str_create(8192);
if (!output) {
return CLI_FAILURE;
}
- if (!ast_tvzero(snapshot->creationtime)) {
- elapsed_seconds = now.tv_sec - snapshot->creationtime.tv_sec;
+ chan = ast_channel_get_by_name(a->argv[3]);
+ if (!chan) {
+ ast_cli(a->fd, "%s is not a known channel\n", a->argv[3]);
+ return CLI_SUCCESS;
+ }
+
+ now = ast_tvnow();
+ ast_channel_lock(chan);
+
+ if (!ast_tvzero(ast_channel_creationtime(chan))) {
+ elapsed_seconds = now.tv_sec - ast_channel_creationtime(chan).tv_sec;
hour = elapsed_seconds / 3600;
min = (elapsed_seconds % 3600) / 60;
sec = elapsed_seconds % 60;
snprintf(cdrtime, sizeof(cdrtime), "%dh%dm%ds", hour, min, sec);
} else {
strcpy(cdrtime, "N/A");
+ }
+
+ ast_translate_path_to_str(ast_channel_writetrans(chan), &write_transpath);
+ ast_translate_path_to_str(ast_channel_readtrans(chan), &read_transpath);
+
+ bridge = ast_channel_get_bridge(chan);
+ callid = ast_channel_callid(chan);
+ if (callid) {
+ ast_callid_strnprint(callid_buf, sizeof(callid_buf), callid);
+ ast_callid_unref(callid);
}
ast_str_append(&output, 0,
@@ -1597,51 +1614,63 @@
" Application: %s\n"
" Data: %s\n"
" Call Identifer: %s\n",
- snapshot->name,
- snapshot->type,
- snapshot->uniqueid,
- snapshot->linkedid,
- S_OR(snapshot->caller_number, "(N/A)"),
- S_OR(snapshot->caller_name, "(N/A)"),
- S_OR(snapshot->connected_number, "(N/A)"),
- S_OR(snapshot->connected_name, "(N/A)"),
- S_OR(snapshot->effective_number, "(N/A)"),
- S_OR(snapshot->effective_name, "(N/A)"),
- S_OR(snapshot->caller_dnid, "(N/A)"),
- snapshot->language,
- ast_state2str(snapshot->state),
- snapshot->state,
- snapshot->nativeformats,
- snapshot->writeformat,
- snapshot->readformat,
- !ast_strlen_zero(snapshot->writetrans) ? "Yes" : "No",
- snapshot->writetrans,
- !ast_strlen_zero(snapshot->readtrans) ? "Yes" : "No",
- snapshot->readtrans,
- (long) snapshot->hanguptime.tv_sec,
+ ast_channel_name(chan),
+ ast_channel_tech(chan)->type,
+ ast_channel_uniqueid(chan),
+ ast_channel_linkedid(chan),
+ S_COR(ast_channel_caller(chan)->id.number.valid,
+ ast_channel_caller(chan)->id.number.str, "(N/A)"),
+ S_COR(ast_channel_caller(chan)->id.name.valid,
+ ast_channel_caller(chan)->id.name.str, "(N/A)"),
+ S_COR(ast_channel_connected(chan)->id.number.valid,
+ ast_channel_connected(chan)->id.number.str, "(N/A)"),
+ S_COR(ast_channel_connected(chan)->id.name.valid,
+ ast_channel_connected(chan)->id.name.str, "(N/A)"),
+ S_COR(ast_channel_connected_effective_id(chan).number.valid,
+ ast_channel_connected_effective_id(chan).number.str, "(N/A)"),
+ S_COR(ast_channel_connected_effective_id(chan).name.valid,
+ ast_channel_connected_effective_id(chan).name.str, "(N/A)"),
+ S_OR(ast_channel_dialed(chan)->number.str, "(N/A)"),
+ ast_channel_language(chan),
+ ast_state2str(ast_channel_state(chan)),
+ ast_channel_state(chan),
+ ast_getformatname_multiple(nativeformats, sizeof(nativeformats), ast_channel_nativeformats(chan)),
+ ast_getformatname(ast_channel_writeformat(chan)),
+ ast_getformatname(ast_channel_readformat(chan)),
+ ast_str_strlen(write_transpath) ? "Yes" : "No",
+ ast_str_buffer(write_transpath),
+ ast_str_strlen(read_transpath) ? "Yes" : "No",
+ ast_str_buffer(read_transpath),
+ ast_channel_whentohangup(chan)->tv_sec,
cdrtime,
- S_OR(snapshot->bridgeid, "(Not bridged)"),
- snapshot->context,
- snapshot->exten,
- snapshot->priority,
- snapshot->callgroup,
- snapshot->pickupgroup,
- S_OR(snapshot->appl, "(N/A)"),
- S_OR(snapshot->data, "(Empty)"),
- S_OR(snapshot->callid, "(None)"));
-
+ bridge ? bridge->uniqueid : "(Not bridged)",
+ ast_channel_context(chan),
+ ast_channel_exten(chan),
+ ast_channel_priority(chan),
+ ast_channel_callgroup(chan),
+ ast_channel_pickupgroup(chan),
+ S_OR(ast_channel_appl(chan), "(N/A)"),
+ S_OR(ast_channel_data(chan), "(Empty)"),
+ S_OR(callid_buf, "(None)")
+ );
ast_str_append(&output, 0, " Variables:\n");
- AST_LIST_TRAVERSE(snapshot->channel_vars, var, entries) {
+ AST_LIST_TRAVERSE(ast_channel_varshead(chan), var, entries) {
ast_str_append(&output, 0, "%s=%s\n", ast_var_name(var), ast_var_value(var));
}
- if (ast_cdr_serialize_variables(snapshot->name, &obuf, '=', '\n')) {
+ if (ast_cdr_serialize_variables(ast_channel_name(chan), &obuf, '=', '\n')) {
ast_str_append(&output, 0, " CDR Variables:\n%s\n", ast_str_buffer(obuf));
}
+
+ ast_channel_unlock(chan);
ast_cli(a->fd, "%s", ast_str_buffer(output));
ast_free(output);
+
+ ao2_cleanup(bridge);
+ ast_channel_unref(chan);
+
return CLI_SUCCESS;
}
Modified: branches/12/main/core_local.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/core_local.c?view=diff&rev=416211&r1=416210&r2=416211
==============================================================================
--- branches/12/main/core_local.c (original)
+++ branches/12/main/core_local.c Fri Jun 13 13:16:34 2014
@@ -328,12 +328,12 @@
RAII_VAR(struct ast_channel_snapshot *, local_one_snapshot, NULL, ao2_cleanup);
RAII_VAR(struct ast_channel_snapshot *, local_two_snapshot, NULL, ao2_cleanup);
- local_one_snapshot = ast_channel_snapshot_create(p->base.owner);
+ local_one_snapshot = ast_channel_snapshot_get_latest(ast_channel_uniqueid(p->base.owner));
if (!local_one_snapshot) {
return NULL;
}
- local_two_snapshot = ast_channel_snapshot_create(p->base.chan);
+ local_two_snapshot = ast_channel_snapshot_get_latest(ast_channel_uniqueid(p->base.chan));
if (!local_two_snapshot) {
return NULL;
}
@@ -371,7 +371,7 @@
if (source) {
RAII_VAR(struct ast_channel_snapshot *, source_snapshot, NULL, ao2_cleanup);
- source_snapshot = ast_channel_snapshot_create(source);
+ source_snapshot = ast_channel_snapshot_get_latest(ast_channel_uniqueid(source));
if (!source_snapshot) {
return;
}
@@ -516,12 +516,12 @@
goto end;
}
- one_snapshot = ast_channel_snapshot_create(owner);
+ one_snapshot = ast_channel_snapshot_get_latest(ast_channel_uniqueid(owner));
if (!one_snapshot) {
goto end;
}
- two_snapshot = ast_channel_snapshot_create(chan);
+ two_snapshot = ast_channel_snapshot_get_latest(ast_channel_uniqueid(chan));
if (!two_snapshot) {
goto end;
}
Modified: branches/12/main/dial.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/dial.c?view=diff&rev=416211&r1=416210&r2=416211
==============================================================================
--- branches/12/main/dial.c (original)
+++ branches/12/main/dial.c Fri Jun 13 13:16:34 2014
@@ -306,7 +306,7 @@
ast_channel_appl_set(channel->owner, "AppDial2");
ast_channel_data_set(channel->owner, "(Outgoing Line)");
- ast_publish_channel_state(channel->owner);
+
memset(ast_channel_whentohangup(channel->owner), 0, sizeof(*ast_channel_whentohangup(channel->owner)));
/* Inherit everything from he who spawned this dial */
Modified: branches/12/main/endpoints.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/endpoints.c?view=diff&rev=416211&r1=416210&r2=416211
==============================================================================
--- branches/12/main/endpoints.c (original)
+++ branches/12/main/endpoints.c Fri Jun 13 13:16:34 2014
@@ -203,9 +203,6 @@
ast_str_container_add(endpoint->channel_ids, ast_channel_uniqueid(chan));
ao2_unlock(endpoint);
- ast_channel_lock(chan);
- ast_publish_channel_state(chan);
- ast_channel_unlock(chan);
endpoint_publish_snapshot(endpoint);
return 0;
Modified: branches/12/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/manager.c?view=diff&rev=416211&r1=416210&r2=416211
==============================================================================
--- branches/12/main/manager.c (original)
+++ branches/12/main/manager.c Fri Jun 13 13:16:34 2014
@@ -99,6 +99,7 @@
#include "asterisk/bridge.h"
#include "asterisk/features_config.h"
#include "asterisk/rtp_engine.h"
+#include "asterisk/translate.h"
/*** DOCUMENTATION
<manager name="Ping" language="en_US">
@@ -3846,95 +3847,110 @@
static int action_status(struct mansession *s, const struct message *m)
{
const char *name = astman_get_header(m, "Channel");
- const char *cvariables = astman_get_header(m, "Variables");
- char *variables = ast_strdupa(S_OR(cvariables, ""));
- RAII_VAR(struct ao2_container *, cached_channels, NULL, ao2_cleanup);
- struct stasis_message *msg;
+ const char *chan_variables = astman_get_header(m, "Variables");
+ const char *id = astman_get_header(m, "ActionID");
+ char *variables = ast_strdupa(S_OR(chan_variables, ""));
+ struct ast_str *variable_str = ast_str_create(1024);
+ struct ast_str *write_transpath = ast_str_alloca(256);
+ struct ast_str *read_transpath = ast_str_alloca(256);
+ struct ast_channel *chan;
+ char nativeformats[256];
int channels = 0;
int all = ast_strlen_zero(name); /* set if we want all channels */
- const char *id = astman_get_header(m, "ActionID");
- char idText[256];
+ char id_text[256];
+ struct ast_channel_iterator *it_chans = NULL;
AST_DECLARE_APP_ARGS(vars,
AST_APP_ARG(name)[100];
);
- struct ast_str *str = ast_str_create(1000);
- struct ao2_iterator it_chans;
- struct timeval now = ast_tvnow();
-
- if (!ast_strlen_zero(id)) {
- snprintf(idText, sizeof(idText), "ActionID: %s\r\n", id);
- } else {
- idText[0] = '\0';
+
+ if (!variable_str) {
+ astman_send_error(s, m, "Memory Allocation Failure");
+ return 1;
}
if (!(function_capable_string_allowed_with_auths(variables, s->session->writeperm))) {
+ ast_free(variable_str);
astman_send_error(s, m, "Status Access Forbidden: Variables");
return 0;
}
if (all) {
- if (!(cached_channels = stasis_cache_dump(ast_channel_cache_by_name(), ast_channel_snapshot_type()))) {
- ast_free(str);
+ if (!(it_chans = ast_channel_iterator_all_new())) {
+ ast_free(variable_str);
astman_send_error(s, m, "Memory Allocation Failure");
return 1;
}
- it_chans = ao2_iterator_init(cached_channels, 0);
- msg = ao2_iterator_next(&it_chans);
+ chan = ast_channel_iterator_next(it_chans);
} else {
- if (!(msg = stasis_cache_get(ast_channel_cache_by_name(), ast_channel_snapshot_type(), name))) {
+ chan = ast_channel_get_by_name(name);
+ if (!chan) {
astman_send_error(s, m, "No such channel");
- ast_free(str);
+ ast_free(variable_str);
return 0;
}
}
astman_send_ack(s, m, "Channel status will follow");
- if (!ast_strlen_zero(cvariables)) {
+ if (!ast_strlen_zero(id)) {
+ snprintf(id_text, sizeof(id_text), "ActionID: %s\r\n", id);
+ } else {
+ id_text[0] = '\0';
+ }
+
+ if (!ast_strlen_zero(chan_variables)) {
AST_STANDARD_APP_ARGS(vars, variables);
}
/* if we look by name, we break after the first iteration */
- for (; msg; ao2_ref(msg, -1), msg = all ? ao2_iterator_next(&it_chans) : NULL) {
- struct ast_channel_snapshot *snapshot = stasis_message_data(msg);
- struct ast_channel *c;
- struct ast_str *built = ast_manager_build_channel_state_string_prefix(snapshot, "");
- long elapsed_seconds = 0;
-
- if (!built) {
- continue;
- }
-
- if (!ast_strlen_zero(cvariables) && (c = ast_channel_get_by_name(snapshot->name))) {
+ for (; chan; all ? chan = ast_channel_iterator_next(it_chans) : 0) {
+ struct timeval now;
+ long elapsed_seconds;
+ struct ast_bridge *bridge;
+
+ ast_channel_lock(chan);
+
+ now = ast_tvnow();
+ elapsed_seconds = ast_tvdiff_sec(now, ast_channel_creationtime(chan));
+
+ if (!ast_strlen_zero(chan_variables)) {
int i;
- ast_str_reset(str);
+ ast_str_reset(variable_str);
for (i = 0; i < vars.argc; i++) {
char valbuf[512], *ret = NULL;
if (vars.name[i][strlen(vars.name[i]) - 1] == ')') {
- if (ast_func_read(c, vars.name[i], valbuf, sizeof(valbuf)) < 0) {
+ if (ast_func_read(chan, vars.name[i], valbuf, sizeof(valbuf)) < 0) {
valbuf[0] = '\0';
}
ret = valbuf;
} else {
- pbx_retrieve_variable(c, vars.name[i], &ret, valbuf, sizeof(valbuf), NULL);
+ pbx_retrieve_variable(chan, vars.name[i], &ret, valbuf, sizeof(valbuf), NULL);
}
- ast_str_append(&str, 0, "Variable: %s=%s\r\n", vars.name[i], ret);
+ ast_str_append(&variable_str, 0, "Variable: %s=%s\r\n", vars.name[i], ret);
}
- ast_channel_unref(c);
}
channels++;
-
- if (!ast_tvzero(snapshot->creationtime)) {
- elapsed_seconds = now.tv_sec - snapshot->creationtime.tv_sec;
- }
+ bridge = ast_channel_get_bridge(chan);
astman_append(s,
"Event: Status\r\n"
"Privilege: Call\r\n"
+ "Channel: %s\r\n"
+ "ChannelState: %u\r\n"
+ "ChannelStateDesc: %s\r\n"
+ "CallerIDNum: %s\r\n"
+ "CallerIDName: %s\r\n"
+ "ConnectedLineNum: %s\r\n"
+ "ConnectedLineName: %s\r\n"
+ "Accountcode: %s\r\n"
+ "Context: %s\r\n"
+ "Exten: %s\r\n"
+ "Priority: %d\r\n"
+ "Uniqueid: %s\r\n"
"Type: %s\r\n"
"DNID: %s\r\n"
"EffectiveConnectedLineNum: %s\r\n"
@@ -3954,43 +3970,56 @@
"Seconds: %ld\r\n"
"%s"
"%s"
- "%s"
"\r\n",
- snapshot->type,
- snapshot->caller_dnid,
- S_OR(snapshot->effective_number, "<unknown>"),
- S_OR(snapshot->effective_name, "<unknown>"),
- snapshot->hanguptime.tv_sec,
- snapshot->bridgeid,
- snapshot->linkedid,
- snapshot->appl,
- snapshot->data,
- snapshot->nativeformats,
- snapshot->readformat,
- snapshot->readtrans,
- snapshot->writeformat,
- snapshot->writetrans,
- snapshot->callgroup,
- snapshot->pickupgroup,
- (long) elapsed_seconds,
- ast_str_buffer(built),
- ast_str_buffer(str),
- idText);
-
- ast_free(built);
- }
-
- if (all) {
- ao2_iterator_destroy(&it_chans);
+ ast_channel_name(chan),
+ ast_channel_state(chan),
+ ast_state2str(ast_channel_state(chan)),
+ S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, "<unknown>"),
+ S_COR(ast_channel_caller(chan)->id.name.valid, ast_channel_caller(chan)->id.name.str, "<unknown>"),
+ S_COR(ast_channel_connected(chan)->id.number.valid, ast_channel_connected(chan)->id.number.str, "<unknown>"),
+ S_COR(ast_channel_connected(chan)->id.name.valid, ast_channel_connected(chan)->id.name.str, "<unknown>"),
+ ast_channel_accountcode(chan),
+ ast_channel_context(chan),
+ ast_channel_exten(chan),
+ ast_channel_priority(chan),
+ ast_channel_uniqueid(chan),
+ ast_channel_tech(chan)->type,
+ S_OR(ast_channel_dialed(chan)->number.str, ""),
+ S_COR(ast_channel_connected_effective_id(chan).number.valid, ast_channel_connected_effective_id(chan).number.str, "<unknown>"),
+ S_COR(ast_channel_connected_effective_id(chan).name.valid, ast_channel_connected_effective_id(chan).name.str, "<unknown>"),
+ ast_channel_whentohangup(chan)->tv_sec,
+ bridge ? bridge->uniqueid : "",
+ ast_channel_linkedid(chan),
+ ast_channel_appl(chan),
+ ast_channel_data(chan),
+ ast_getformatname_multiple(nativeformats, sizeof(nativeformats), ast_channel_nativeformats(chan)),
+ ast_getformatname(ast_channel_readformat(chan)),
+ ast_translate_path_to_str(ast_channel_readtrans(chan), &read_transpath),
+ ast_getformatname(ast_channel_writeformat(chan)),
+ ast_translate_path_to_str(ast_channel_writetrans(chan), &write_transpath),
+ ast_channel_callgroup(chan),
+ ast_channel_pickupgroup(chan),
+ (long)elapsed_seconds,
+ ast_str_buffer(variable_str),
+ id_text);
+
+ ao2_cleanup(bridge);
+
+ ast_channel_unlock(chan);
+ chan = ast_channel_unref(chan);
+ }
+
+ if (it_chans) {
+ ast_channel_iterator_destroy(it_chans);
}
astman_append(s,
"Event: StatusComplete\r\n"
"%s"
"Items: %d\r\n"
- "\r\n", idText, channels);
-
- ast_free(str);
+ "\r\n", id_text, channels);
+
+ ast_free(variable_str);
return 0;
}
Modified: branches/12/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/pbx.c?view=diff&rev=416211&r1=416210&r2=416211
==============================================================================
--- branches/12/main/pbx.c (original)
+++ branches/12/main/pbx.c Fri Jun 13 13:16:34 2014
@@ -8343,8 +8343,7 @@
/*! \brief CLI support for listing chanvar's variables in a parseable way */
static char *handle_show_chanvar(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
- RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
- struct ast_channel_snapshot *snapshot;
+ struct ast_channel *chan;
struct ast_var_t *var;
switch (cmd) {
@@ -8358,19 +8357,23 @@
return ast_complete_channels(a->line, a->word, a->pos, a->n, 3);
}
- if (a->argc != e->args + 1)
+ if (a->argc != e->args + 1) {
return CLI_SHOWUSAGE;
-
- if (!(msg = stasis_cache_get(ast_channel_cache_by_name(), ast_channel_snapshot_type(), a->argv[3]))) {
+ }
+
+ chan = ast_channel_get_by_name(a->argv[e->args]);
+ if (!chan) {
ast_cli(a->fd, "Channel '%s' not found\n", a->argv[e->args]);
return CLI_FAILURE;
}
- snapshot = stasis_message_data(msg);
-
- AST_LIST_TRAVERSE(snapshot->channel_vars, var, entries) {
+
+ ast_channel_lock(chan);
+ AST_LIST_TRAVERSE(ast_channel_varshead(chan), var, entries) {
ast_cli(a->fd, "%s=%s\n", ast_var_name(var), ast_var_value(var));
}
-
+ ast_channel_unlock(chan);
+
+ ast_channel_unref(chan);
return CLI_SUCCESS;
}
@@ -10163,7 +10166,7 @@
struct ast_app *app = pbx_findapp(outgoing->app);
if (app) {
- ast_verb(4, "Launching %s(%s) on %s\n", outgoing->app, outgoing->appdata,
+ ast_verb(4, "Launching %s(%s) on %s\n", outgoing->app, S_OR(outgoing->appdata, ""),
ast_channel_name(ast_dial_answered(outgoing->dial)));
pbx_exec(ast_dial_answered(outgoing->dial), app, outgoing->appdata);
} else {
@@ -11420,14 +11423,11 @@
AST_LIST_TRAVERSE_SAFE_END;
if (value && (newvariable = ast_var_assign(name, value))) {
- if (headp == &globals)
+ if (headp == &globals) {
ast_verb(2, "Setting global variable '%s' to '%s'\n", name, value);
+ }
AST_LIST_INSERT_HEAD(headp, newvariable, entries);
ast_channel_publish_varset(chan, name, value);
-
- if (headp != &globals) {
- ast_channel_publish_snapshot(chan);
- }
}
if (chan)
Modified: branches/12/main/pickup.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/pickup.c?view=diff&rev=416211&r1=416210&r2=416211
==============================================================================
--- branches/12/main/pickup.c (original)
+++ branches/12/main/pickup.c Fri Jun 13 13:16:34 2014
@@ -361,9 +361,7 @@
goto pickup_failed;
}
- ast_channel_lock(target);
- target_snapshot = ast_channel_snapshot_create(target);
- ast_channel_unlock(target);
+ target_snapshot = ast_channel_snapshot_get_latest(ast_channel_uniqueid(target));
if (!target_snapshot) {
goto pickup_failed;
}
Modified: branches/12/main/stasis_bridges.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/stasis_bridges.c?view=diff&rev=416211&r1=416210&r2=416211
==============================================================================
--- branches/12/main/stasis_bridges.c (original)
+++ branches/12/main/stasis_bridges.c Fri Jun 13 13:16:34 2014
@@ -407,9 +407,7 @@
}
if (chan) {
- ast_channel_lock(chan);
- obj->channel = ast_channel_snapshot_create(chan);
- ast_channel_unlock(chan);
+ obj->channel = ast_channel_snapshot_get_latest(ast_channel_uniqueid(chan));
if (obj->channel == NULL) {
return NULL;
}
@@ -593,9 +591,7 @@
}
}
[... 363 lines stripped ...]
More information about the asterisk-commits
mailing list