aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorbbryant <bbryant@f38db490-d61c-443f-a65b-d21fe96a405b>2007-06-22 14:53:08 +0000
committerbbryant <bbryant@f38db490-d61c-443f-a65b-d21fe96a405b>2007-06-22 14:53:08 +0000
commitc75cc8c67fee0512dd7e6996a0d55bfe2f57f4f4 (patch)
tree5454e74732a13108e3bafa75d5858258e22dbb4b /main
parent166cd282d00488e747d4e2765ae18f4842d07f80 (diff)
Merged revisions 71064 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2 ........ r71064 | bbryant | 2007-06-22 09:39:34 -0500 (Fri, 22 Jun 2007) | 10 lines Fixed infinite loop when controlling terminal was lost and return value of input function wasn't checked for errors. This would cause 100% cpu to be taken up. (closes issue #9654, issue #10010) Reported by: mnicholson, and eserra Idea for the patch from mnicholson, patched by me ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@71066 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r--main/asterisk.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/main/asterisk.c b/main/asterisk.c
index 0c36fda6a..d0c3d2e4e 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -2282,6 +2282,9 @@ static void ast_remotecontrol(char * data)
for (;;) {
ebuf = (char *)el_gets(el, &num);
+ if (!ebuf)
+ break;
+
if (!ast_strlen_zero(ebuf)) {
if (ebuf[strlen(ebuf)-1] == '\n')
ebuf[strlen(ebuf)-1] = '\0';
@@ -2956,12 +2959,14 @@ int main(int argc, char *argv[])
for (;;) {
buf = (char *)el_gets(el, &num);
- if (buf) {
- if (buf[strlen(buf)-1] == '\n')
- buf[strlen(buf)-1] = '\0';
+ if (!buf)
+ break;
+
+ if (buf[strlen(buf)-1] == '\n')
+ buf[strlen(buf)-1] = '\0';
+ consolehandler((char *)buf);
- consolehandler((char *)buf);
- } else if (ast_opt_remote && (write(STDOUT_FILENO, "\nUse EXIT or QUIT to exit the asterisk console\n",
+ if (!buf && ast_opt_remote && (write(STDOUT_FILENO, "\nUse EXIT or QUIT to exit the asterisk console\n",
strlen("\nUse EXIT or QUIT to exit the asterisk console\n")) < 0)) {
/* Whoa, stdout disappeared from under us... Make /dev/null's */
int fd;