[Asterisk-cvs] asterisk asterisk.c,1.43,1.44 cli.c,1.26,1.27

markster at lists.digium.com markster at lists.digium.com
Tue Dec 2 20:36:50 CST 2003


Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv4183

Modified Files:
	asterisk.c cli.c 
Log Message:
Minor patch for improving console response with asterisk -r (bug #183)


Index: asterisk.c
===================================================================
RCS file: /usr/cvsroot/asterisk/asterisk.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- asterisk.c	1 Dec 2003 02:47:19 -0000	1.43
+++ asterisk.c	3 Dec 2003 03:03:15 -0000	1.44
@@ -167,6 +167,7 @@
 	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 @@
 		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 @@
 			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 {

Index: cli.c
===================================================================
RCS file: /usr/cvsroot/asterisk/cli.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- cli.c	9 Nov 2003 20:31:54 -0000	1.26
+++ cli.c	3 Dec 2003 03:03:15 -0000	1.27
@@ -1009,6 +1009,7 @@
 					ast_cli(fd, e->usage);
 					break;
 				}
+				ast_cli(fd, "\n\n");
 			} else 
 				ast_cli(fd, "No such command '%s' (type 'help' for help)\n", find_best(argv));
 			if (e) {




More information about the svn-commits mailing list