summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Bryant <russell@russellbryant.com>2007-01-23 22:09:23 +0000
committerRussell Bryant <russell@russellbryant.com>2007-01-23 22:09:23 +0000
commitac884e0c3ac65ed3d717ab39ced5e81f12b62b83 (patch)
treec35e35a686730ce8532bfa291f76be0aebc6d727
parentd2aac799100594c9e3a29ae82f3915c05a8d4a60 (diff)
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) ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@51787 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r--main/manager.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/main/manager.c b/main/manager.c
index 8144ccead..ca83f3c00 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -2068,28 +2068,39 @@ static int process_message(struct mansession *s, const struct message *m)
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 */