[asterisk-commits] russell: trunk r51751 - in /trunk: ./ main/manager.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Jan 23 14:38:32 MST 2007


Author: russell
Date: Tue Jan 23 15:38:31 2007
New Revision: 51751

URL: http://svn.digium.com/view/asterisk?view=rev&rev=51751
Log:
Merged revisions 51750 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r51750 | russell | 2007-01-23 15:33:15 -0600 (Tue, 23 Jan 2007) | 4 lines

When traversing the list of manager actions, the iterator needs to be
initialized to the list head *after* locking the list.  Also, lock the actions
list in one place it is being accessed where it was not being done.

........

Modified:
    trunk/   (props changed)
    trunk/main/manager.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/main/manager.c
URL: http://svn.digium.com/view/asterisk/trunk/main/manager.c?view=diff&rev=51751&r1=51750&r2=51751
==============================================================================
--- trunk/main/manager.c (original)
+++ trunk/main/manager.c Tue Jan 23 15:38:31 2007
@@ -2076,18 +2076,18 @@
 		astman_send_error(s, m, "Permission denied");
 		return 0;
 	}
-	/* XXX should we protect the list navigation ? */
+	ast_mutex_lock(&actionlock);	
 	for (tmp = first_action ; tmp; tmp = tmp->next) {
-		if (!strcasecmp(action, tmp->action)) {
-			if ((s->writeperm & tmp->authority) == tmp->authority) {
-				if (tmp->func(s, m))	/* error */
-					return -1;
-			} else {
-				astman_send_error(s, m, "Permission denied");
-			}
-			break;
-		}
-	}
+		if (strcasecmp(action, tmp->action))
+			continue;
+		if ((s->writeperm & tmp->authority) == tmp->authority) {
+			if (tmp->func(s, m))	/* error */
+				return -1;
+		} else
+			astman_send_error(s, m, "Permission denied");
+		break;
+	}
+	ast_mutex_unlock(&actionlock);
 	if (!tmp)
 		astman_send_error(s, m, "Invalid/unknown command. Use Action: ListCommands to show available commands.");
 	if (ret)
@@ -2389,7 +2389,7 @@
  */
 int ast_manager_unregister(char *action)
 {
-	struct manager_action *cur = first_action, *prev = first_action;
+	struct manager_action *cur, *prev;
 
 	ast_mutex_lock(&actionlock);
 	for (cur = first_action, prev = NULL; cur; prev = cur, cur = cur->next) {



More information about the asterisk-commits mailing list