diff options
Diffstat (limited to 'main/asterisk.c')
-rw-r--r-- | main/asterisk.c | 52 |
1 files changed, 21 insertions, 31 deletions
diff --git a/main/asterisk.c b/main/asterisk.c index d55594983..77046f272 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -607,6 +607,9 @@ static char *handle_show_settings(struct ast_cli_entry *e, int cmd, struct ast_c ast_cli(a->fd, " Transmit silence during rec: %s\n", ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSMIT_SILENCE) ? "Enabled" : "Disabled"); ast_cli(a->fd, " Generic PLC: %s\n", ast_test_flag(&ast_options, AST_OPT_FLAG_GENERIC_PLC) ? "Enabled" : "Disabled"); ast_cli(a->fd, " Min DTMF duration:: %u\n", option_dtmfminduration); +#if !defined(LOW_MEMORY) + ast_cli(a->fd, " Cache media frames: %s\n", ast_opt_cache_media_frames ? "Enabled" : "Disabled"); +#endif ast_cli(a->fd, " RTP use dynamic payloads: %u\n", ast_option_rtpusedynamic); if (ast_option_rtpptdynamic == AST_RTP_PT_LAST_REASSIGN) { @@ -1761,15 +1764,13 @@ static struct sigaction urg_handler = { static void _hup_handler(int num) { - int a = 0, save_errno = errno; + int save_errno = errno; printf("Received HUP signal -- Reloading configs\n"); if (restartnow) execvp(_argv[0], _argv); sig_flags.need_reload = 1; - if (sig_alert_pipe[1] != -1) { - if (write(sig_alert_pipe[1], &a, sizeof(a)) < 0) { - fprintf(stderr, "hup_handler: write() failed: %s\n", strerror(errno)); - } + if (ast_alertpipe_write(sig_alert_pipe)) { + fprintf(stderr, "hup_handler: write() failed: %s\n", strerror(errno)); } errno = save_errno; } @@ -2169,10 +2170,7 @@ static void really_quit(int num, shutdown_nice_t niceness, int restart) close(ast_consock); if (!ast_opt_remote) unlink(ast_config_AST_PID); - if (sig_alert_pipe[0]) - close(sig_alert_pipe[0]); - if (sig_alert_pipe[1]) - close(sig_alert_pipe[1]); + ast_alertpipe_close(sig_alert_pipe); printf("%s", term_quit()); if (restart) { int i; @@ -2208,12 +2206,9 @@ static void really_quit(int num, shutdown_nice_t niceness, int restart) static void __quit_handler(int num) { - int a = 0; sig_flags.need_quit = 1; - if (sig_alert_pipe[1] != -1) { - if (write(sig_alert_pipe[1], &a, sizeof(a)) < 0) { - fprintf(stderr, "quit_handler: write() failed: %s\n", strerror(errno)); - } + if (ast_alertpipe_write(sig_alert_pipe)) { + fprintf(stderr, "quit_handler: write() failed: %s\n", strerror(errno)); } /* There is no need to restore the signal handler here, since the app * is going to exit */ @@ -2466,16 +2461,6 @@ static char *handle_version(struct ast_cli_entry *e, int cmd, struct ast_cli_arg return CLI_SUCCESS; } -#if 0 -static int handle_quit(int fd, int argc, char *argv[]) -{ - if (argc != 1) - return RESULT_SHOWUSAGE; - quit_handler(0, SHUTDOWN_NORMAL, 0); - return RESULT_SUCCESS; -} -#endif - static char *handle_stop_now(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { @@ -3665,7 +3650,6 @@ static void ast_readconfig(void) ast_copy_string(cfg_paths.agi_dir, v->value, sizeof(cfg_paths.agi_dir)); } else if (!strcasecmp(v->name, "astrundir")) { snprintf(cfg_paths.pid_path, sizeof(cfg_paths.pid_path), "%s/%s", v->value, "asterisk.pid"); - snprintf(cfg_paths.socket_path, sizeof(cfg_paths.socket_path), "%s/%s", v->value, ast_config_AST_CTL); ast_copy_string(cfg_paths.run_dir, v->value, sizeof(cfg_paths.run_dir)); } else if (!strcasecmp(v->name, "astmoddir")) { ast_copy_string(cfg_paths.module_dir, v->value, sizeof(cfg_paths.module_dir)); @@ -3674,6 +3658,10 @@ static void ast_readconfig(void) } } + /* Combine astrundir and astctl settings. */ + snprintf(cfg_paths.socket_path, sizeof(cfg_paths.socket_path), "%s/%s", + ast_config_AST_RUN_DIR, ast_config_AST_CTL); + for (v = ast_variable_browse(cfg, "options"); v; v = v->next) { /* verbose level (-v at startup) */ if (!strcasecmp(v->name, "verbose")) { @@ -3724,6 +3712,11 @@ static void ast_readconfig(void) /* Cache recorded sound files to another directory during recording */ } else if (!strcasecmp(v->name, "cache_record_files")) { ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_CACHE_RECORD_FILES); +#if !defined(LOW_MEMORY) + /* Cache media frames for performance */ + } else if (!strcasecmp(v->name, "cache_media_frames")) { + ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_CACHE_MEDIA_FRAMES); +#endif /* Specify cache directory */ } else if (!strcasecmp(v->name, "record_cache_dir")) { ast_copy_string(record_cache_dir, v->value, AST_CACHE_DIR_LEN); @@ -3887,7 +3880,7 @@ static void *monitor_sig_flags(void *unused) { for (;;) { struct pollfd p = { sig_alert_pipe[0], POLLIN, 0 }; - int a; + ast_poll(&p, 1, -1); if (sig_flags.need_reload) { sig_flags.need_reload = 0; @@ -3902,8 +3895,7 @@ static void *monitor_sig_flags(void *unused) quit_handler(0, SHUTDOWN_NORMAL, 0); } } - if (read(sig_alert_pipe[0], &a, sizeof(a)) != sizeof(a)) { - } + ast_alertpipe_read(sig_alert_pipe); } return NULL; @@ -4710,9 +4702,7 @@ static void asterisk_daemon(int isroot, const char *runuser, const char *rungrou consolethread = pthread_self(); } - if (pipe(sig_alert_pipe)) { - sig_alert_pipe[0] = sig_alert_pipe[1] = -1; - } + ast_alertpipe_init(sig_alert_pipe); ast_process_pending_reloads(); |