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

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Jan 23 15:09:23 MST 2007


Author: russell
Date: Tue Jan 23 16:09:23 2007
New Revision: 51787

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

........
r51781 | russell | 2007-01-23 16:04:01 -0600 (Tue, 23 Jan 2007) | 6 lines

Fix some bugs in process_message().  The manager session lock needs to be held
when sending some sort of response, or calling one of the manager action
callbacks.  This resolves an issue where people using the GUI would get random
crashes when they start clicking around a lot.
(issue #8711, reported and debugged by zandbelt)

........

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=51787&r1=51786&r2=51787
==============================================================================
--- trunk/main/manager.c (original)
+++ trunk/main/manager.c Tue Jan 23 16:09:23 2007
@@ -2068,28 +2068,39 @@
 		ast_log(LOG_DEBUG, "Manager received command '%s'\n", action);
 
 	if (ast_strlen_zero(action)) {
+		ast_mutex_lock(&s->__lock);
 		astman_send_error(s, m, "Missing action in request");
+		ast_mutex_unlock(&s->__lock);
 		return 0;
 	}
 
 	if (!s->authenticated && strcasecmp(action, "Login") && strcasecmp(action, "Logoff") && strcasecmp(action, "Challenge")) {
+		ast_mutex_lock(&s->__lock);
 		astman_send_error(s, m, "Permission denied");
+		ast_mutex_unlock(&s->__lock);
 		return 0;
 	}
 	ast_mutex_lock(&actionlock);	
 	for (tmp = first_action ; tmp; tmp = tmp->next) {
 		if (strcasecmp(action, tmp->action))
 			continue;
+		ast_mutex_lock(&s->__lock);
 		if ((s->writeperm & tmp->authority) == tmp->authority) {
-			if (tmp->func(s, m))	/* error */
+			if (tmp->func(s, m)) {	/* error */
+				ast_mutex_unlock(&s->__lock);
 				return -1;
+			}
 		} else
 			astman_send_error(s, m, "Permission denied");
+		ast_mutex_unlock(&s->__lock);
 		break;
 	}
 	ast_mutex_unlock(&actionlock);
-	if (!tmp)
+	if (!tmp) {
+		ast_mutex_lock(&s->__lock);
 		astman_send_error(s, m, "Invalid/unknown command. Use Action: ListCommands to show available commands.");
+		ast_mutex_unlock(&s->__lock);
+	}
 	if (ret)
 		return ret;
 	/* Once done with our message, deliver any pending events */



More information about the asterisk-commits mailing list