[asterisk-commits] russell: trunk r133945 - /trunk/main/devicestate.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Jul 26 10:15:14 CDT 2008


Author: russell
Date: Sat Jul 26 10:15:14 2008
New Revision: 133945

URL: http://svn.digium.com/view/asterisk?view=rev&rev=133945
Log:
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.

Modified:
    trunk/main/devicestate.c

Modified: trunk/main/devicestate.c
URL: http://svn.digium.com/view/asterisk/trunk/main/devicestate.c?view=diff&rev=133945&r1=133944&r2=133945
==============================================================================
--- trunk/main/devicestate.c (original)
+++ trunk/main/devicestate.c Sat Jul 26 10:15:14 2008
@@ -327,7 +327,7 @@
 }
 
 /*! \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 @@
 	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 @@
 {
 	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));
 




More information about the asterisk-commits mailing list