aboutsummaryrefslogtreecommitdiffstats
path: root/main/devicestate.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-07-25 17:24:43 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-07-25 17:24:43 +0000
commit917670b3314afc014e974ab1456a2ebbf514dbbf (patch)
tree4a04810816158f70796c59c825e7169d5f83417b /main/devicestate.c
parent6e93150ec206d524e69f71536f32c6d91c749d30 (diff)
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: http://svn.digium.com/svn/asterisk/trunk@133665 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/devicestate.c')
-rw-r--r--main/devicestate.c39
1 files changed, 5 insertions, 34 deletions
diff --git a/main/devicestate.c b/main/devicestate.c
index 6e0af66a0..c7fe08e39 100644
--- a/main/devicestate.c
+++ b/main/devicestate.c
@@ -457,15 +457,11 @@ static void do_state_change(const char *device)
devstate_event(device, state, CACHE_OFF);
}
-static int __ast_devstate_changed_literal(enum ast_device_state state, char *buf, int norecurse)
+int ast_devstate_changed_literal(enum ast_device_state state, const char *device)
{
- 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);
@@ -482,37 +478,12 @@ static int __ast_devstate_changed_literal(enum ast_device_state state, char *buf
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, ...)
@@ -524,7 +495,7 @@ int ast_devstate_changed(enum ast_device_state state, const char *fmt, ...)
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 */
@@ -537,7 +508,7 @@ int ast_device_state_changed(const char *fmt, ...)
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 */