diff --git a/asterisk.c b/asterisk.c index a73307be00..83a2e4635f 100755 --- a/asterisk.c +++ b/asterisk.c @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include #include #include @@ -102,8 +104,9 @@ static void *netconsole(void *vconsole) } if (FD_ISSET(con->fd, &rfds)) { res = read(con->fd, tmp, sizeof(tmp)); - if (res < 1) + if (res < 1) { break; + } tmp[res] = 0; ast_cli_command(con->fd, tmp); } @@ -134,6 +137,7 @@ static void *listener(void *unused) int s; int len; int x; + int flags; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); @@ -145,13 +149,15 @@ static void *listener(void *unused) } else { for (x=0;xcmda); if (find_cli(e->cmda, -1)) { - ast_log(LOG_WARNING, "Command '%s' already registered (or something close enough)\n", fulle); ast_pthread_mutex_unlock(&clilock); + ast_log(LOG_WARNING, "Command '%s' already registered (or something close enough)\n", fulle); return -1; } cur = helpers; @@ -655,7 +655,7 @@ static char *__ast_cli_generator(char *text, char *word, int state, int lock) join(fullcmd2, sizeof(fullcmd2), e2->cmda); if (e1->cmda[0]) join(fullcmd1, sizeof(fullcmd1), e1->cmda); - if (!e1->cmda || + if (!e1->cmda[0] || (e2 && (strcmp(fullcmd2, fullcmd1) < 0))) { /* Use e2 */ e = e2;