Minor patch for improving console response with asterisk -r (bug #183)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@1817 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
parent
72a198dfa8
commit
22f776a8e1
11
asterisk.c
11
asterisk.c
|
@ -167,6 +167,7 @@ static void *netconsole(void *vconsole)
|
||||||
int res;
|
int res;
|
||||||
int max;
|
int max;
|
||||||
fd_set rfds;
|
fd_set rfds;
|
||||||
|
struct timeval tv;
|
||||||
|
|
||||||
if (gethostname(hostname, sizeof(hostname)))
|
if (gethostname(hostname, sizeof(hostname)))
|
||||||
strncpy(hostname, "<Unknown>", sizeof(hostname)-1);
|
strncpy(hostname, "<Unknown>", sizeof(hostname)-1);
|
||||||
|
@ -179,11 +180,17 @@ static void *netconsole(void *vconsole)
|
||||||
max = con->fd;
|
max = con->fd;
|
||||||
if (con->p[0] > max)
|
if (con->p[0] > max)
|
||||||
max = con->p[0];
|
max = con->p[0];
|
||||||
res = ast_select(max + 1, &rfds, NULL, NULL, NULL);
|
tv.tv_sec = 4; /* Wait max 4 sec for fds to become active */
|
||||||
|
tv.tv_usec = 0;
|
||||||
|
res = ast_select(max + 1, &rfds, NULL, NULL, &tv);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
ast_log(LOG_WARNING, "select returned < 0: %s\n", strerror(errno));
|
ast_log(LOG_WARNING, "select returned < 0: %s\n", strerror(errno));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (res == 0) {
|
||||||
|
ast_log(LOG_WARNING, "Timeout on select.\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (FD_ISSET(con->fd, &rfds)) {
|
if (FD_ISSET(con->fd, &rfds)) {
|
||||||
res = read(con->fd, tmp, sizeof(tmp));
|
res = read(con->fd, tmp, sizeof(tmp));
|
||||||
if (res < 1) {
|
if (res < 1) {
|
||||||
|
@ -794,7 +801,7 @@ static int ast_el_read_char(EditLine *el, char *cp)
|
||||||
if (!option_exec && !lastpos)
|
if (!option_exec && !lastpos)
|
||||||
write(STDOUT_FILENO, "\r", 1);
|
write(STDOUT_FILENO, "\r", 1);
|
||||||
write(STDOUT_FILENO, buf, res);
|
write(STDOUT_FILENO, buf, res);
|
||||||
if ((buf[res-1] == '\n') || (buf[res-2] == '\n')) {
|
if ((buf[res-1] == '\n') && (buf[res-2] == '\n')) {
|
||||||
*cp = CC_REFRESH;
|
*cp = CC_REFRESH;
|
||||||
return(1);
|
return(1);
|
||||||
} else {
|
} else {
|
||||||
|
|
1
cli.c
1
cli.c
|
@ -1009,6 +1009,7 @@ int ast_cli_command(int fd, char *s)
|
||||||
ast_cli(fd, e->usage);
|
ast_cli(fd, e->usage);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
ast_cli(fd, "\n\n");
|
||||||
} else
|
} else
|
||||||
ast_cli(fd, "No such command '%s' (type 'help' for help)\n", find_best(argv));
|
ast_cli(fd, "No such command '%s' (type 'help' for help)\n", find_best(argv));
|
||||||
if (e) {
|
if (e) {
|
||||||
|
|
Reference in New Issue