mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
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 ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@133665 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -272,6 +272,18 @@ static void agent_devicestate_cb(const struct ast_event *event, void *unused)
|
||||
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) {
|
||||
@@ -282,14 +294,6 @@ static void agent_devicestate_cb(const struct ast_event *event, void *unused)
|
||||
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;
|
||||
}
|
||||
|
||||
AST_LIST_TRAVERSE(&agents, p, list) {
|
||||
ast_mutex_lock(&p->lock);
|
||||
if (p->chan) {
|
||||
@@ -514,6 +518,7 @@ static struct ast_frame *agent_read(struct ast_channel *ast)
|
||||
}
|
||||
p->chan = NULL;
|
||||
p->inherited_devicestate = -1;
|
||||
ast_device_state_changed("Agent/%s", p->agent);
|
||||
p->acknowledged = 0;
|
||||
}
|
||||
} else {
|
||||
@@ -729,6 +734,7 @@ static int agent_call(struct ast_channel *ast, char *dest, int timeout)
|
||||
/* Agent hung-up */
|
||||
p->chan = NULL;
|
||||
p->inherited_devicestate = -1;
|
||||
ast_device_state_changed("Agent/%s", p->agent);
|
||||
}
|
||||
|
||||
if (!res) {
|
||||
@@ -850,6 +856,7 @@ static int agent_hangup(struct ast_channel *ast)
|
||||
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))) {
|
||||
|
Reference in New Issue
Block a user