[asterisk-commits] qwell: branch 1.4 r97618 - /branches/1.4/main/cli.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jan 9 14:05:46 CST 2008


Author: qwell
Date: Wed Jan  9 14:05:45 2008
New Revision: 97618

URL: http://svn.digium.com/view/asterisk?view=rev&rev=97618
Log:
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.

Modified:
    branches/1.4/main/cli.c

Modified: branches/1.4/main/cli.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/cli.c?view=diff&rev=97618&r1=97617&r2=97618
==============================================================================
--- branches/1.4/main/cli.c (original)
+++ branches/1.4/main/cli.c Wed Jan  9 14:05:45 2008
@@ -1755,10 +1755,11 @@
 		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 @@
 {
 	char fullcmd[80];
 	struct ast_cli_entry *e;
+	int res = RESULT_SUCCESS;
 
 	if (argc < 1)
 		return RESULT_SHOWUSAGE;
@@ -1778,8 +1780,11 @@
 
 	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 @@
 		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)




More information about the asterisk-commits mailing list