[asterisk-commits] russell: branch russell/chan_refcount r82480 - /team/russell/chan_refcount/main/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Sep 14 17:31:03 CDT 2007
Author: russell
Date: Fri Sep 14 17:31:02 2007
New Revision: 82480
URL: http://svn.digium.com/view/asterisk?view=rev&rev=82480
Log:
convert action_status
Modified:
team/russell/chan_refcount/main/manager.c
Modified: team/russell/chan_refcount/main/manager.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/main/manager.c?view=diff&rev=82480&r1=82479&r2=82480
==============================================================================
--- team/russell/chan_refcount/main/manager.c (original)
+++ team/russell/chan_refcount/main/manager.c Fri Sep 14 17:31:02 2007
@@ -1643,37 +1643,44 @@
static int action_status(struct mansession *s, const struct message *m)
{
const char *name = astman_get_header(m,"Channel");
- struct ast_channel *c;
+ struct ast_channel *c = NULL;
char bridge[256];
struct timeval now = ast_tvnow();
long elapsed_seconds = 0;
int all = ast_strlen_zero(name); /* set if we want all channels */
const char *id = astman_get_header(m,"ActionID");
char idText[256] = "";
+ struct ast_channel_iterator *iter = NULL;
if (!ast_strlen_zero(id))
snprintf(idText, sizeof(idText), "ActionID: %s\r\n", id);
- if (all)
- c = ast_channel_walk_locked(NULL);
- else {
- c = ast_get_channel_by_name_locked(name);
- if (!c) {
+ if (all) {
+ iter = ast_channel_iterator_all_new();
+ if (iter)
+ c = ast_channel_iterator_next(iter);
+ } else {
+ if (!(c = ast_channel_get_by_name(name))) {
astman_send_error(s, m, "No such channel");
return 0;
}
}
+
astman_send_ack(s, m, "Channel status will follow");
+
/* if we look by name, we break after the first iteration */
while (c) {
+ ast_channel_lock(c);
+
if (c->_bridge)
snprintf(bridge, sizeof(bridge), "Link: %s\r\n", c->_bridge->name);
else
bridge[0] = '\0';
+
if (c->pbx) {
- if (c->cdr) {
+ if (c->cdr)
elapsed_seconds = now.tv_sec - c->cdr->start.tv_sec;
- }
+
astman_append(s,
"Event: Status\r\n"
"Privilege: Call\r\n"
@@ -1715,15 +1722,24 @@
c->accountcode,
ast_state2str(c->_state), bridge, c->uniqueid, idText);
}
+
ast_channel_unlock(c);
+ ast_channel_unref(c);
+
if (!all)
break;
- c = ast_channel_walk_locked(c);
- }
+
+ c = ast_channel_iterator_next(iter);
+ }
+
+ if (iter)
+ ast_channel_iterator_destroy(iter);
+
astman_append(s,
"Event: StatusComplete\r\n"
"%s"
"\r\n",idText);
+
return 0;
}
More information about the asterisk-commits
mailing list