summaryrefslogtreecommitdiff
path: root/asterisk.c
diff options
context:
space:
mode:
authorMark Spencer <markster@digium.com>2003-12-03 03:03:15 +0000
committerMark Spencer <markster@digium.com>2003-12-03 03:03:15 +0000
commit8f276e00c5fa41851fc81cf52a92afbad583c83a (patch)
tree54460062d2cd537ae397b681a38c559642fbbe41 /asterisk.c
parent3171dea6ef091cdddbe76420cce10f5b17808778 (diff)
Minor patch for improving console response with asterisk -r (bug #183)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1817 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'asterisk.c')
-rwxr-xr-xasterisk.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/asterisk.c b/asterisk.c
index 37efe8029..0659cb431 100755
--- a/asterisk.c
+++ b/asterisk.c
@@ -167,6 +167,7 @@ static void *netconsole(void *vconsole)
int res;
int max;
fd_set rfds;
+ struct timeval tv;
if (gethostname(hostname, sizeof(hostname)))
strncpy(hostname, "<Unknown>", sizeof(hostname)-1);
@@ -179,11 +180,17 @@ static void *netconsole(void *vconsole)
max = con->fd;
if (con->p[0] > max)
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) {
ast_log(LOG_WARNING, "select returned < 0: %s\n", strerror(errno));
continue;
}
+ if (res == 0) {
+ ast_log(LOG_WARNING, "Timeout on select.\n");
+ break;
+ }
if (FD_ISSET(con->fd, &rfds)) {
res = read(con->fd, tmp, sizeof(tmp));
if (res < 1) {
@@ -794,7 +801,7 @@ static int ast_el_read_char(EditLine *el, char *cp)
if (!option_exec && !lastpos)
write(STDOUT_FILENO, "\r", 1);
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;
return(1);
} else {