aboutsummaryrefslogtreecommitdiffstats
path: root/main/cli.c
diff options
context:
space:
mode:
authorqwell <qwell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-01-09 20:05:45 +0000
committerqwell <qwell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-01-09 20:05:45 +0000
commitc523b3d54337d9b45b2028244a81a203ae865854 (patch)
treec81c8c89934ac048e45f4ae3c548bf95f33f6d19 /main/cli.c
parenteec22c4659d306f3315b9210a9530f1647a11b27 (diff)
Fix some locking and return value funkiness. We really shouldn't be unlocking this lock inside of a function, unless we locked it there too.
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@97618 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/cli.c')
-rw-r--r--main/cli.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/main/cli.c b/main/cli.c
index 8b5087883..eee61b5cd 100644
--- a/main/cli.c
+++ b/main/cli.c
@@ -1755,10 +1755,11 @@ static int help1(int fd, char *match[], int locked)
ast_cli(fd, "%25.25s %s\n", e->_full_cmd, S_OR(e->summary, ""));
found++;
}
- AST_LIST_UNLOCK(&helpers);
+ if (!locked)
+ AST_LIST_UNLOCK(&helpers);
if (!locked && !found && matchstr[0])
ast_cli(fd, "No such command '%s'.\n", matchstr);
- return 0;
+ return RESULT_SUCCESS;
}
static int help_workhorse(int fd, char *match[])
@@ -1770,6 +1771,7 @@ static int handle_help(int fd, int argc, char *argv[])
{
char fullcmd[80];
struct ast_cli_entry *e;
+ int res = RESULT_SUCCESS;
if (argc < 1)
return RESULT_SHOWUSAGE;
@@ -1778,8 +1780,11 @@ static int handle_help(int fd, int argc, char *argv[])
AST_LIST_LOCK(&helpers);
e = find_cli(argv + 1, 1); /* try exact match first */
- if (!e)
- return help1(fd, argv + 1, 1 /* locked */);
+ if (!e) {
+ res = help1(fd, argv + 1, 1 /* locked */);
+ AST_LIST_UNLOCK(&helpers);
+ return res;
+ }
if (e->usage)
ast_cli(fd, "%s", e->usage);
else {
@@ -1787,7 +1792,7 @@ static int handle_help(int fd, int argc, char *argv[])
ast_cli(fd, "No help text available for '%s'.\n", fullcmd);
}
AST_LIST_UNLOCK(&helpers);
- return RESULT_SUCCESS;
+ return res;
}
static char *parse_args(const char *s, int *argc, char *argv[], int max, int *trailingwhitespace)