[asterisk-commits] russell: trunk r62673 - in /trunk: CHANGES channels/chan_local.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed May 2 08:46:49 MST 2007


Author: russell
Date: Wed May  2 10:46:49 2007
New Revision: 62673

URL: http://svn.digium.com/view/asterisk?view=rev&rev=62673
Log:
Update the device state functionality of chan_local such that it will return
NOT_INUSE or INUSE when Local channels are in use as opposed to just UNKNOWN.
It will still return INVALID if the extension doesn't exist at all.
(issue #8048, patch from tim_ringenbach)

Modified:
    trunk/CHANGES
    trunk/channels/chan_local.c

Modified: trunk/CHANGES
URL: http://svn.digium.com/view/asterisk/trunk/CHANGES?view=diff&rev=62673&r1=62672&r2=62673
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Wed May  2 10:46:49 2007
@@ -182,3 +182,6 @@
      back to the person that did the transfer if the transfer is not successful.
      See the options "atxferdropcall", "atxferloopdelay", and "atxfercallbackretries"
      in features.conf.sample.
+  * The device state functionality in the Local channel driver has been updated
+     to indicate INUSE or NOT_INUSE when a Local channel is being used as opposed
+     to just UNKNOWN if the extension exists.

Modified: trunk/channels/chan_local.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_local.c?view=diff&rev=62673&r1=62672&r2=62673
==============================================================================
--- trunk/channels/chan_local.c (original)
+++ trunk/channels/chan_local.c Wed May  2 10:46:49 2007
@@ -129,6 +129,7 @@
 	char *exten = ast_strdupa(data);
 	char *context = NULL, *opts = NULL;
 	int res;
+	struct local_pvt *lp;
 
 	if (!(context = strchr(exten, '@'))) {
 		ast_log(LOG_WARNING, "Someone used Local/%s somewhere without a @context. This is bad.\n", exten);
@@ -143,11 +144,22 @@
 
 	if (option_debug > 2)
 		ast_log(LOG_DEBUG, "Checking if extension %s@%s exists (devicestate)\n", exten, context);
+
 	res = ast_exists_extension(NULL, context, exten, 1, NULL);
 	if (!res)		
 		return AST_DEVICE_INVALID;
-	else
-		return AST_DEVICE_UNKNOWN;
+	
+	res = AST_DEVICE_NOT_INUSE;
+	AST_LIST_LOCK(&locals);
+	AST_LIST_TRAVERSE(&locals, lp, list) {
+		if (!strcmp(exten, lp->exten) && !strcmp(context, lp->context) && lp->owner) {
+			res = AST_DEVICE_INUSE;
+			break;
+		}
+	}
+	AST_LIST_UNLOCK(&locals);
+
+	return res;
 }
 
 static int local_queue_frame(struct local_pvt *p, int isoutbound, struct ast_frame *f, struct ast_channel *us)



More information about the asterisk-commits mailing list