diff options
Diffstat (limited to 'asterisk.c')
-rwxr-xr-x | asterisk.c | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/asterisk.c b/asterisk.c index 3c4d230ee..113e5a172 100755 --- a/asterisk.c +++ b/asterisk.c @@ -247,13 +247,15 @@ static void network_verboser(const char *s, int pos, int replace, int complete) char *t = alloca(strlen(s) + 2); if (t) { sprintf(t, "\r%s", s); - ast_network_puts(t); + if (complete) + ast_network_puts(t); } else { ast_log(LOG_ERROR, "Out of memory\n"); ast_network_puts(s); } } else { - ast_network_puts(s); + if (complete) + ast_network_puts(s); } } @@ -757,12 +759,12 @@ static char shutdown_when_convenient_help[] = static char restart_now_help[] = "Usage: restart now\n" -" Causes Asterisk to hangup all calls and exec() itself performing a cold.\n" +" Causes Asterisk to hangup all calls and exec() itself performing a cold\n" " restart.\n"; static char restart_gracefully_help[] = "Usage: restart gracefully\n" -" Causes Asterisk to stop accepting new calls and exec() itself performing a cold.\n" +" Causes Asterisk to stop accepting new calls and exec() itself performing a cold\n" " restart when all active calls have ended.\n"; static char restart_when_convenient_help[] = @@ -925,7 +927,7 @@ static int ast_el_read_char(EditLine *el, char *cp) usleep(1000000 / reconnects_per_second); } } - if (tries >= 30) { + if (tries >= 30 * reconnects_per_second) { fprintf(stderr, "Failed to reconnect for 30 seconds. Quitting.\n"); quit_handler(0, 0, 0, 0); } @@ -1471,13 +1473,13 @@ static int show_cli_help(void) { printf(" -f Do not fork\n"); printf(" -g Dump core in case of a crash\n"); printf(" -h This help screen\n"); - printf(" -i Initializie crypto keys at startup\n"); + printf(" -i Initialize crypto keys at startup\n"); printf(" -n Disable console colorization\n"); printf(" -p Run as pseudo-realtime thread\n"); - printf(" -q Quiet mode (supress output)\n"); + printf(" -q Quiet mode (suppress output)\n"); printf(" -r Connect to Asterisk on this machine\n"); printf(" -R Connect to Asterisk, and attempt to reconnect if disconnected\n"); - printf(" -t Record soundfiles in /tmp and move them where they belong after they are done.\n"); + printf(" -t Record soundfiles in /var/tmp and move them where they belong after they are done.\n"); printf(" -v Increase verbosity (multiple v's = more verbose)\n"); printf(" -x <cmd> Execute command <cmd> (only valid with -r)\n"); printf("\n"); @@ -1579,6 +1581,7 @@ int main(int argc, char *argv[]) int num; char *buf; char *runuser=NULL, *rungroup=NULL; + struct pollfd silly_macos[1]; /* Remember original args for restart */ if (argc > sizeof(_argv) / sizeof(_argv[0]) - 1) { @@ -1728,10 +1731,6 @@ int main(int argc, char *argv[]) printf(term_end()); fflush(stdout); - /* Test recursive mutex locking. */ - if (test_for_thread_safety()) - ast_verbose("Warning! Asterisk is not thread safe.\n"); - if (option_console && !option_verbose) ast_verbose("[ Reading Master Configuration ]"); ast_readconfig(); @@ -1796,6 +1795,10 @@ int main(int argc, char *argv[]) ast_log(LOG_WARNING, "Unable to open pid file '%s': %s\n", (char *)ast_config_AST_PID, strerror(errno)); } + /* Test recursive mutex locking. */ + if (test_for_thread_safety()) + ast_verbose("Warning! Asterisk is not thread safe.\n"); + ast_makesocket(); sigemptyset(&sigs); sigaddset(&sigs, SIGHUP); @@ -1905,15 +1908,24 @@ int main(int argc, char *argv[]) consolehandler((char *)buf); } else { - if (option_remote) - ast_cli(STDOUT_FILENO, "\nUse EXIT or QUIT to exit the asterisk console\n"); + if (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; + fd = open("/dev/null", O_RDWR); + if (fd > -1) { + dup2(fd, STDOUT_FILENO); + dup2(fd, STDIN_FILENO); + } else + ast_log(LOG_WARNING, "Failed to open /dev/null to recover from dead console. Bad things will happen!\n"); + break; + } } } - } else { - /* Do nothing */ - for(;;) - poll(NULL,0, -1); } + /* Do nothing */ + for(;;) + poll(silly_macos,0, -1); return 0; } |