summaryrefslogtreecommitdiff
path: root/main/devicestate.c
diff options
context:
space:
mode:
authorRussell Bryant <russell@russellbryant.com>2008-07-26 15:15:14 +0000
committerRussell Bryant <russell@russellbryant.com>2008-07-26 15:15:14 +0000
commitac79d99fa66ed75baaa3076b6e34defc1562d729 (patch)
tree28d3fa92bf2e97e897ae6b0cecbb93e8696d6489 /main/devicestate.c
parentc978cc1e2646874c91ad721ad6f989f2af7560da (diff)
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. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@133945 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/devicestate.c')
-rw-r--r--main/devicestate.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/main/devicestate.c b/main/devicestate.c
index b27413cfb..97c9c06ca 100644
--- a/main/devicestate.c
+++ b/main/devicestate.c
@@ -327,7 +327,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;
@@ -379,6 +379,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)
{
@@ -465,7 +473,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));