aboutsummaryrefslogtreecommitdiffstats
path: root/main/devicestate.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-07-26 15:17:46 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-07-26 15:17:46 +0000
commitda7a9c9d779fa600f7feb55d5514ca5454b8d0f8 (patch)
treeed333b89c74b5a923ca780f41a18938d6c9b536c /main/devicestate.c
parentf4ad248bdf6ebba681e74cc30ad8b8c28b9274b1 (diff)
Merged revisions 133945-133946 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ........ r133945 | russell | 2008-07-26 10:15:14 -0500 (Sat, 26 Jul 2008) | 6 lines ast_device_state() gets called in two different ways. The first way is when called from elsewhere in Asterisk to find the current state of a device. In that case, we want to use the cached value if it exists. The other way is when processing a device state change. In that case, we do not want to check the cache because returning the last known state is counter productive. ........ r133946 | russell | 2008-07-26 10:16:20 -0500 (Sat, 26 Jul 2008) | 1 line actually use the cache_cache argument ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@133947 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/devicestate.c')
-rw-r--r--main/devicestate.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/main/devicestate.c b/main/devicestate.c
index 8c62b177c..10813c4c0 100644
--- a/main/devicestate.c
+++ b/main/devicestate.c
@@ -286,7 +286,7 @@ static enum ast_device_state devstate_cached(const char *device)
}
/*! \brief Check device state through channel specific function or generic function */
-enum ast_device_state ast_device_state(const char *device)
+static enum ast_device_state _ast_device_state(const char *device, int check_cache)
{
char *buf;
char *number;
@@ -298,9 +298,12 @@ enum ast_device_state ast_device_state(const char *device)
char *provider = NULL;
/* If the last known state is cached, just return that */
- res = devstate_cached(device);
- if (res != AST_DEVICE_UNKNOWN)
- return res;
+ if (check_cache) {
+ res = devstate_cached(device);
+ if (res != AST_DEVICE_UNKNOWN) {
+ return res;
+ }
+ }
buf = ast_strdupa(device);
tech = strsep(&buf, "/");
@@ -338,6 +341,14 @@ enum ast_device_state ast_device_state(const char *device)
return res;
}
+enum ast_device_state ast_device_state(const char *device)
+{
+ /* This function is called from elsewhere in the code to find out the
+ * current state of a device. Check the cache, first. */
+
+ return _ast_device_state(device, 1);
+}
+
/*! \brief Add device state provider */
int ast_devstate_prov_add(const char *label, ast_devstate_prov_cb_type callback)
{
@@ -425,7 +436,7 @@ static void do_state_change(const char *device)
{
enum ast_device_state state;
- state = ast_device_state(device);
+ state = _ast_device_state(device, 0);
ast_debug(3, "Changing state for %s - state %d (%s)\n", device, state, devstate2str(state));