aboutsummaryrefslogtreecommitdiffstats
path: root/main/devicestate.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-07-25 17:19:39 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-07-25 17:19:39 +0000
commit1c852c16ad8f394f8e6b8793286ca199630a1a88 (patch)
tree2cd3fa538b72b1c5dff3ed9c8a14dbc083d6637b /main/devicestate.c
parent958638e4ee206b2b2b18d79d939518bc3c0336a2 (diff)
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/branches/1.4@133649 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/devicestate.c')
-rw-r--r--main/devicestate.c29
1 files changed, 3 insertions, 26 deletions
diff --git a/main/devicestate.c b/main/devicestate.c
index cc647a823..f84c87df7 100644
--- a/main/devicestate.c
+++ b/main/devicestate.c
@@ -294,17 +294,13 @@ static void do_state_change(const char *device)
ast_hint_state_changed(device);
}
-static int __ast_device_state_changed_literal(char *buf, int norecurse)
+int ast_device_state_changed_literal(const char *device)
{
- char *device;
struct state_change *change;
- char *tmp = NULL;
if (option_debug > 2)
- ast_log(LOG_DEBUG, "Notification of state change to be queued on device/channel %s\n", buf);
+ ast_log(LOG_DEBUG, "Notification of state change to be queued on device/channel %s\n", device);
- device = buf;
-
if (change_thread == AST_PTHREADT_NULL || !(change = ast_calloc(1, sizeof(*change) + strlen(device)))) {
/* we could not allocate a change struct, or */
/* there is no background thread, so process the change now */
@@ -320,28 +316,9 @@ static int __ast_device_state_changed_literal(char *buf, int norecurse)
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_device_state_changed_literal(device, 1);
- }
-
return 1;
}
-int ast_device_state_changed_literal(const char *dev)
-{
- char *buf;
- buf = ast_strdupa(dev);
- return __ast_device_state_changed_literal(buf, 0);
-}
-
/*! \brief Accept change notification, add it to change queue */
int ast_device_state_changed(const char *fmt, ...)
{
@@ -351,7 +328,7 @@ int ast_device_state_changed(const char *fmt, ...)
va_start(ap, fmt);
vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
- return __ast_device_state_changed_literal(buf, 0);
+ return ast_device_state_changed_literal(buf);
}
/*! \brief Go through the dev state change queue and update changes in the dev state thread */