[asterisk-commits] tilghman: branch 1.6.0 r133671 - in /branches/1.6.0: ./ channels/ main/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Jul 25 12:26:39 CDT 2008
Author: tilghman
Date: Fri Jul 25 12:26:38 2008
New Revision: 133671
URL: http://svn.digium.com/view/asterisk?view=rev&rev=133671
Log:
Merged revisions 133665 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r133665 | tilghman | 2008-07-25 12:24:43 -0500 (Fri, 25 Jul 2008) | 16 lines
Merged revisions 133649 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r133649 | tilghman | 2008-07-25 12:19:39 -0500 (Fri, 25 Jul 2008) | 8 lines
Fix some errant device states by making the devicestate API more strict in
terms of the device argument (only without the unique identifier appended).
(closes issue #12771)
Reported by: davidw
Patches:
20080717__bug12771.diff.txt uploaded by Corydon76 (license 14)
Tested by: davidw, jvandal, murf
........
................
Modified:
branches/1.6.0/ (props changed)
branches/1.6.0/channels/chan_agent.c
branches/1.6.0/main/channel.c
branches/1.6.0/main/devicestate.c
Propchange: branches/1.6.0/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.
Modified: branches/1.6.0/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/channels/chan_agent.c?view=diff&rev=133671&r1=133670&r2=133671
==============================================================================
--- branches/1.6.0/channels/chan_agent.c (original)
+++ branches/1.6.0/channels/chan_agent.c Fri Jul 25 12:26:38 2008
@@ -265,6 +265,18 @@
const char *device;
enum ast_device_state state;
+ state = ast_event_get_ie_uint(event, AST_EVENT_IE_STATE);
+ device = ast_event_get_ie_str(event, AST_EVENT_IE_DEVICE);
+
+ if (ast_strlen_zero(device)) {
+ return;
+ }
+
+ /* Skip Agent status */
+ if (!strncasecmp(device, "Agent/", 6)) {
+ return;
+ }
+
/* Try to be safe, but don't deadlock */
for (i = 0; i < 10; i++) {
if ((res = AST_LIST_TRYLOCK(&agents)) == 0) {
@@ -272,14 +284,6 @@
}
}
if (res) {
- return;
- }
-
- state = ast_event_get_ie_uint(event, AST_EVENT_IE_STATE);
- device = ast_event_get_ie_str(event, AST_EVENT_IE_DEVICE);
-
- if (ast_strlen_zero(device)) {
- AST_LIST_UNLOCK(&agents);
return;
}
@@ -505,6 +509,7 @@
}
p->chan = NULL;
p->inherited_devicestate = -1;
+ ast_device_state_changed("Agent/%s", p->agent);
p->acknowledged = 0;
}
} else {
@@ -720,6 +725,7 @@
/* Agent hung-up */
p->chan = NULL;
p->inherited_devicestate = -1;
+ ast_device_state_changed("Agent/%s", p->agent);
}
if (!res) {
@@ -841,6 +847,7 @@
ast_hangup(p->chan);
p->chan = NULL;
p->inherited_devicestate = -1;
+ ast_device_state_changed("Agent/%s", p->agent);
}
ast_debug(1, "Hungup, howlong is %d, autologoff is %d\n", howlong, p->autologoff);
if ((p->deferlogoff) || (howlong && p->autologoff && (howlong > p->autologoff))) {
Modified: branches/1.6.0/main/channel.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/main/channel.c?view=diff&rev=133671&r1=133670&r2=133671
==============================================================================
--- branches/1.6.0/main/channel.c (original)
+++ branches/1.6.0/main/channel.c Fri Jul 25 12:26:38 2008
@@ -1262,7 +1262,7 @@
struct ast_frame *f;
struct varshead *headp;
struct ast_datastore *datastore = NULL;
- char name[AST_CHANNEL_NAME];
+ char name[AST_CHANNEL_NAME], *dashptr;
headp=&chan->varshead;
@@ -1295,6 +1295,9 @@
sched_context_destroy(chan->sched);
ast_copy_string(name, chan->name, sizeof(name));
+ if ((dashptr = strrchr(name, '-'))) {
+ *dashptr = '\0';
+ }
/* Stop monitoring */
if (chan->monitor)
@@ -4068,12 +4071,18 @@
int ast_setstate(struct ast_channel *chan, enum ast_channel_state state)
{
int oldstate = chan->_state;
+ char name[AST_CHANNEL_NAME], *dashptr;
if (oldstate == state)
return 0;
+ ast_copy_string(name, chan->name, sizeof(name));
+ if ((dashptr = strrchr(name, '-'))) {
+ *dashptr = '\0';
+ }
+
chan->_state = state;
- ast_device_state_changed_literal(chan->name);
+ ast_device_state_changed_literal(name);
/* setstate used to conditionally report Newchannel; this is no more */
manager_event(EVENT_FLAG_CALL,
"Newstate",
Modified: branches/1.6.0/main/devicestate.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/main/devicestate.c?view=diff&rev=133671&r1=133670&r2=133671
==============================================================================
--- branches/1.6.0/main/devicestate.c (original)
+++ branches/1.6.0/main/devicestate.c Fri Jul 25 12:26:38 2008
@@ -432,15 +432,11 @@
devstate_event(device, state, CACHE_OFF);
}
-static int __ast_devstate_changed_literal(enum ast_device_state state, char *buf, int norecurse)
-{
- char *device;
+int ast_devstate_changed_literal(enum ast_device_state state, const char *device)
+{
struct state_change *change;
- char *tmp = NULL;
-
- ast_debug(3, "Notification of state change to be queued on device/channel %s\n", buf);
-
- device = buf;
+
+ ast_debug(3, "Notification of state change to be queued on device/channel %s\n", device);
if (state != AST_DEVICE_UNKNOWN) {
devstate_event(device, state, CACHE_ON);
@@ -457,37 +453,12 @@
AST_LIST_UNLOCK(&state_changes);
}
- /* The problem with this API is that a device may be called with the unique
- * identifier appended or not, but it's separated from the channel name
- * with a '-', which is also a legitimate character in a channel name. So,
- * we have to force both names to get their names checked for state changes
- * to ensure that the right one gets notified. Not a huge performance hit,
- * but it might could be fixed by an enterprising programmer in trunk.
- */
- if (!norecurse && (tmp = strrchr(device, '-'))) {
- *tmp = '\0';
- __ast_devstate_changed_literal(state, device, 1);
- }
-
return 1;
}
-int ast_devstate_changed_literal(enum ast_device_state state, const char *dev)
-{
- char *buf;
-
- buf = ast_strdupa(dev);
-
- return __ast_devstate_changed_literal(state, buf, 0);
-}
-
int ast_device_state_changed_literal(const char *dev)
{
- char *buf;
-
- buf = ast_strdupa(dev);
-
- return __ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, buf, 0);
+ return ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, dev);
}
int ast_devstate_changed(enum ast_device_state state, const char *fmt, ...)
@@ -499,7 +470,7 @@
vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
- return __ast_devstate_changed_literal(state, buf, 0);
+ return ast_devstate_changed_literal(state, buf);
}
/*! \brief Accept change notification, add it to change queue */
@@ -512,7 +483,7 @@
vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
- return __ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, buf, 0);
+ return ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, buf);
}
/*! \brief Go through the dev state change queue and update changes in the dev state thread */
More information about the asterisk-commits
mailing list