[asterisk-commits] russell: branch russell/chan_refcount r96369 - in /team/russell/chan_refcount...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Jan 3 16:17:25 CST 2008
Author: russell
Date: Thu Jan 3 16:17:25 2008
New Revision: 96369
URL: http://svn.digium.com/view/asterisk?view=rev&rev=96369
Log:
- update res_agi for new API
- merge in support for finding channel by uniqueid, which was just added to trunk
- sync with some other trunk changes
Modified:
team/russell/chan_refcount/ (props changed)
team/russell/chan_refcount/include/asterisk/channel.h
team/russell/chan_refcount/main/channel.c
team/russell/chan_refcount/res/res_agi.c
team/russell/chan_refcount/res/res_config_pgsql.c
Propchange: team/russell/chan_refcount/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.
Propchange: team/russell/chan_refcount/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu Jan 3 16:17:25 2008
@@ -1,1 +1,1 @@
-/trunk:1-96295
+/trunk:1-96367
Modified: team/russell/chan_refcount/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/include/asterisk/channel.h?view=diff&rev=96369&r1=96368&r2=96369
==============================================================================
--- team/russell/chan_refcount/include/asterisk/channel.h (original)
+++ team/russell/chan_refcount/include/asterisk/channel.h Thu Jan 3 16:17:25 2008
@@ -1635,7 +1635,7 @@
/*!
* \brief Create a new channel iterator based on name
*
- * \arg name channel name to match
+ * \arg name channel name or channel uniqueid to match
* \arg name_len number of characters in the channel name to match on. This
* would be used to match based on name prefix. If matching on the full
* channel name is desired, then this parameter should be 0.
@@ -1693,7 +1693,7 @@
/*!
* \brief Find a channel by name
*
- * \arg name the name of the channel to search for
+ * \arg name the name or uniqueid of the channel to search for
*
* Find a channel that has the same name as the provided argument.
*
@@ -1705,7 +1705,7 @@
/*!
* \brief Find a channel by a name prefix
*
- * \arg name The channel name prefix to search for
+ * \arg name The channel name or uniqueid prefix to search for
* \arg name_len Only search for up to this many characters from the name
*
* Find a channel that has the same name prefix as specified by the arguments.
Modified: team/russell/chan_refcount/main/channel.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/main/channel.c?view=diff&rev=96369&r1=96368&r2=96369
==============================================================================
--- team/russell/chan_refcount/main/channel.c (original)
+++ team/russell/chan_refcount/main/channel.c Thu Jan 3 16:17:25 2008
@@ -1085,9 +1085,14 @@
for (; (chan = ao2_iterator_next(&i->i)); ast_channel_unref(chan)) {
if (i->name) { /* match by name */
- if ((!i->name_len && strcasecmp(chan->name, i->name)) ||
- (i->name_len && strncasecmp(chan->name, i->name, i->name_len)))
- continue; /* name match failed */
+ if (!i->name_len) {
+ if (strcasecmp(chan->name, i->name) && strcasecmp(chan->uniqueid, i->name))
+ continue; /* name match failed */
+ } else {
+ if (strncasecmp(chan->name, i->name, i->name_len) &&
+ strncasecmp(chan->uniqueid, i->name, i->name_len))
+ continue; /* name match failed */
+ }
} else if (i->exten) {
if (i->context && strcasecmp(chan->context, i->context) &&
strcasecmp(chan->macrocontext, i->context))
@@ -3501,10 +3506,10 @@
struct ast_cdr *cdr;
int rformat = original->readformat;
int wformat = original->writeformat;
- char newn[100];
- char orig[100];
- char masqn[100];
- char zombn[100];
+ char newn[AST_CHANNEL_NAME];
+ char orig[AST_CHANNEL_NAME];
+ char masqn[AST_CHANNEL_NAME];
+ char zombn[AST_CHANNEL_NAME];
ast_debug(4, "Actually Masquerading %s(%d) into the structure of %s(%d)\n",
clone->name, clone->_state, original->name, original->_state);
@@ -3627,7 +3632,7 @@
ast_channel_unlock(clone);
return -1;
}
-
+
snprintf(zombn, sizeof(zombn), "%s<ZOMBIE>", orig);
/* Mangle the name of the clone channel */
ast_string_field_set(clone, name, zombn);
@@ -3637,7 +3642,7 @@
t_pvt = original->monitor;
original->monitor = clone->monitor;
clone->monitor = t_pvt;
-
+
/* Keep the same language. */
ast_string_field_set(original, language, clone->language);
/* Copy the FD's other than the generator fd */
@@ -3671,16 +3676,16 @@
tmpcid = original->cid;
original->cid = clone->cid;
clone->cid = tmpcid;
-
+
/* Restore original timing file descriptor */
ast_channel_set_fd(original, AST_TIMING_FD, original->timingfd);
-
+
/* Our native formats are different now */
original->nativeformats = clone->nativeformats;
-
+
/* Context, extension, priority, app data, jump table, remain the same */
/* pvt switches. pbx stays the same, as does next */
-
+
/* Set the write format */
ast_set_write_format(original, wformat);
@@ -3709,7 +3714,7 @@
/* If an indication is currently playing maintain it on the channel that is taking the place of original */
if (original->visible_indication)
ast_indicate(original, original->visible_indication);
-
+
/* Now, at this point, the "clone" channel is totally F'd up. We mark it as
a zombie so nothing tries to touch it. If it's already been marked as a
zombie, then free it now (since it already is considered invalid). */
@@ -3733,7 +3738,7 @@
ast_queue_frame(clone, &ast_null_frame);
ast_channel_unlock(clone);
}
-
+
/* Signal any blocker */
if (ast_test_flag(original, AST_FLAG_BLOCKING))
pthread_kill(original->blocker, SIGURG);
Modified: team/russell/chan_refcount/res/res_agi.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/res/res_agi.c?view=diff&rev=96369&r1=96368&r2=96369
==============================================================================
--- team/russell/chan_refcount/res/res_agi.c (original)
+++ team/russell/chan_refcount/res/res_agi.c Thu Jan 3 16:17:25 2008
@@ -299,18 +299,27 @@
if (a->argc < 4)
return CLI_SHOWUSAGE;
- chan = ast_get_channel_by_name_locked(a->argv[2]);
+
+ chan = ast_channel_get_by_name(a->argv[2]);
if (!chan) {
ast_log(LOG_WARNING, "Channel %s does not exists or cannot lock it\n", a->argv[2]);
return CLI_FAILURE;
}
+
+ ast_channel_lock(chan);
+
if (add_agi_cmd(chan, a->argv[3], (a->argc > 4 ? a->argv[4] : ""))) {
ast_log(LOG_WARNING, "failed to add AGI command to queue of channel %s\n", chan->name);
ast_channel_unlock(chan);
+ ast_channel_unref(chan);
return CLI_FAILURE;
}
+
ast_log(LOG_DEBUG, "Added AGI command to channel %s queue\n", chan->name);
+
ast_channel_unlock(chan);
+ ast_channel_unref(chan);
+
return CLI_SUCCESS;
}
@@ -332,24 +341,32 @@
const char *cmdid = astman_get_header(m, "CommandID");
struct ast_channel *chan;
char buf[256];
+
if (ast_strlen_zero(channel) || ast_strlen_zero(cmdbuff)) {
astman_send_error(s, m, "Both, Channel and Command are *required*");
return 0;
}
- chan = ast_get_channel_by_name_locked(channel);
+
+ chan = ast_channel_get_by_name(channel);
if (!chan) {
snprintf(buf, sizeof(buf), "Channel %s does not exists or cannot get its lock", channel);
astman_send_error(s, m, buf);
return 1;
}
+
if (add_agi_cmd(chan, cmdbuff, cmdid)) {
snprintf(buf, sizeof(buf), "Failed to add AGI command to channel %s queue", chan->name);
+ ast_channel_unlock(chan);
+ ast_channel_unref(chan);
astman_send_error(s, m, buf);
- ast_channel_unlock(chan);
return 1;
}
+
+ ast_channel_unlock(chan);
+ ast_channel_unref(chan);
+
astman_send_ack(s, m, "Added AGI command to queue");
- ast_channel_unlock(chan);
+
return 0;
}
Modified: team/russell/chan_refcount/res/res_config_pgsql.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/res/res_config_pgsql.c?view=diff&rev=96369&r1=96368&r2=96369
==============================================================================
--- team/russell/chan_refcount/res/res_config_pgsql.c (original)
+++ team/russell/chan_refcount/res/res_config_pgsql.c Thu Jan 3 16:17:25 2008
@@ -665,7 +665,7 @@
struct ast_variable *new_v;
struct ast_category *cur_cat = NULL;
char sqlbuf[1024] = "";
- char *sql;
+ char *sql = sqlbuf;
size_t sqlleft = sizeof(sqlbuf);
char last[80] = "";
int last_cat_metric = 0;
More information about the asterisk-commits
mailing list