diff options
author | Kevin P. Fleming <kpfleming@digium.com> | 2005-09-30 23:44:12 +0000 |
---|---|---|
committer | Kevin P. Fleming <kpfleming@digium.com> | 2005-09-30 23:44:12 +0000 |
commit | a08f3f75ffca68a756a0ff8983be36ff8cbb8c15 (patch) | |
tree | 5b4e6f1a794f4c85cab6b320e4714dbf139d5c62 | |
parent | 7f429e3b02bc0f8214db28986ae56fa410ac4b63 (diff) |
tell the user about invalid/unknown commands before sending queued events
s->challenge does not need to be protected by the lock, since only process_message() (and functions it calls) ever use it, and process_message() is a blocking operation by definition
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6703 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rwxr-xr-x | manager.c | 13 |
1 files changed, 5 insertions, 8 deletions
@@ -1223,11 +1223,8 @@ static int process_message(struct mansession *s, struct message *m) char *authtype; authtype = astman_get_header(m, "AuthType"); if (!strcasecmp(authtype, "MD5")) { - if (!s->challenge || ast_strlen_zero(s->challenge)) { - ast_mutex_lock(&s->__lock); + if (!s->challenge || ast_strlen_zero(s->challenge)) snprintf(s->challenge, sizeof(s->challenge), "%d", rand()); - ast_mutex_unlock(&s->__lock); - } ast_mutex_lock(&s->__lock); ast_cli(s->fd, "Response: Success\r\n" "%s" @@ -1277,6 +1274,10 @@ static int process_message(struct mansession *s, struct message *m) } tmp = tmp->next; } + if (!ret) + astman_send_error(s, m, "Invalid/unknown command"); + else + ret = 0; ast_mutex_lock(&s->__lock); s->busy = 0; while(s->eventq) { @@ -1289,10 +1290,6 @@ static int process_message(struct mansession *s, struct message *m) free(eqe); } ast_mutex_unlock(&s->__lock); - if (!ret) - astman_send_error(s, m, "Invalid/unknown command"); - else - ret = 0; return ret; } return 0; |