Asterisk - The Open Source Telephony Project GIT-master-754dea3
|
Top level source file for Asterisk - the Open Source PBX. Implementation of PBX core functions and CLI interface. More...
#include "asterisk.h"
#include "asterisk/_private.h"
#include <sys/time.h>
#include <fcntl.h>
#include <signal.h>
#include <sched.h>
#include <sys/un.h>
#include <sys/wait.h>
#include <ctype.h>
#include <sys/resource.h>
#include <grp.h>
#include <pwd.h>
#include <sys/stat.h>
#include <sys/sysinfo.h>
#include <regex.h>
#include <histedit.h>
#include "asterisk/paths.h"
#include "asterisk/network.h"
#include "asterisk/cli.h"
#include "asterisk/channel.h"
#include "asterisk/translate.h"
#include "asterisk/pickup.h"
#include "asterisk/acl.h"
#include "asterisk/ulaw.h"
#include "asterisk/alaw.h"
#include "asterisk/callerid.h"
#include "asterisk/image.h"
#include "asterisk/tdd.h"
#include "asterisk/term.h"
#include "asterisk/manager.h"
#include "asterisk/cdr.h"
#include "asterisk/pbx.h"
#include "asterisk/app.h"
#include "asterisk/mwi.h"
#include "asterisk/lock.h"
#include "asterisk/utils.h"
#include "asterisk/file.h"
#include "asterisk/io.h"
#include "asterisk/config.h"
#include "asterisk/ast_version.h"
#include "asterisk/linkedlists.h"
#include "asterisk/devicestate.h"
#include "asterisk/presencestate.h"
#include "asterisk/module.h"
#include "asterisk/buildinfo.h"
#include "asterisk/xmldoc.h"
#include "asterisk/poll-compat.h"
#include "asterisk/test.h"
#include "asterisk/rtp_engine.h"
#include "asterisk/format.h"
#include "asterisk/aoc.h"
#include "asterisk/uuid.h"
#include "asterisk/sorcery.h"
#include "asterisk/bucket.h"
#include "asterisk/stasis.h"
#include "asterisk/json.h"
#include "asterisk/stasis_endpoints.h"
#include "asterisk/stasis_system.h"
#include "asterisk/security_events.h"
#include "asterisk/endpoints.h"
#include "asterisk/codec.h"
#include "asterisk/format_cache.h"
#include "asterisk/media_cache.h"
#include "asterisk/astdb.h"
#include "asterisk/options.h"
#include "asterisk/utf8.h"
#include "../defaults.h"
Go to the source code of this file.
Data Structures | |
struct | ast_atexit |
struct | atexits |
struct | console |
struct | console_state_data |
struct | profile_data |
struct | profile_entry |
struct | thread_list |
struct | thread_list_t |
Macros | |
#define | AF_LOCAL AF_UNIX |
#define | AST_MAX_CONNECTS 128 |
#define | ASTERISK_PROMPT "*CLI> " |
#define | CHAR_T_LIBEDIT wchar_t |
#define | CHAR_TO_LIBEDIT(c) btowc(c) |
#define | CMD_MATCHESARRAY "_COMMAND MATCHESARRAY \"%s\" \"%s\"" |
#define | COPYRIGHT_TAG "Copyright (C) 1999 - 2025, Sangoma Technologies Corporation and others." |
#define | DEFINE_PROFILE_MIN_MAX_VALUES |
#define | EL_BUF_SIZE 512 |
#define | MAX_HISTORY_COMMAND_LENGTH 256 |
#define | NUM_MSGS 64 |
#define | PF_LOCAL PF_UNIX |
#define | SHUTDOWN_TIMEOUT 15 /* Seconds */ |
#define | WELCOME_MESSAGE |
Welcome message when starting a CLI interface. More... | |
Enumerations | |
enum | shutdown_nice_t { NOT_SHUTTING_DOWN , SHUTTING_DOWN_FINAL , SHUTTING_DOWN , SHUTDOWN_FAST , SHUTDOWN_NORMAL , SHUTDOWN_NICE , SHUTDOWN_REALLY_NICE } |
enum | startup_commands_phase { STARTUP_COMMANDS_PRE_INIT = 0 , STARTUP_COMMANDS_PRE_MODULE , STARTUP_COMMANDS_FULLY_BOOTED } |
Functions | |
static void | __ast_unregister_atexit (void(*func)(void)) |
static void | __init_console_state (void) |
static void | __quit_handler (int num) |
static void | __remote_quit_handler (int num) |
static void | _child_handler (int sig) |
static void | _hup_handler (int num) |
static void | _null_sig_handler (int sig) |
NULL handler so we can collect the child exit status. More... | |
static void | _urg_handler (int num) |
Urgent handler. More... | |
int | ast_add_profile (const char *name, uint64_t scale) |
allocates a counter with a given name and scale. More... | |
static int | ast_all_zeros (const char *s) |
static void | ast_begin_shutdown (void) |
int | ast_cancel_shutdown (void) |
Cancel an existing shutdown and return to normal operation. More... | |
static void | ast_cli_display_match_list (struct ast_vector_string *matches, int max) |
void | ast_console_puts (const char *string) |
write the string to the root console, and all attached network console clients More... | |
void | ast_console_puts_mutable (const char *string, int level) |
log the string to the root console, and all attached network console clients More... | |
void | ast_console_puts_mutable_full (const char *message, int level, int sublevel) |
log the string to the console, and all attached console clients More... | |
void | ast_console_toggle_loglevel (int fd, int level, int state) |
enable or disable a logging level to a specified console More... | |
void | ast_console_toggle_mute (int fd, int silent) |
mute or unmute a console from logging More... | |
static int | ast_el_add_history (const char *) |
static int | ast_el_initialize (void) |
static int | ast_el_read_char (EditLine *editline, CHAR_T_LIBEDIT *cp) |
static void | ast_el_read_default_histfile (void) |
static int | ast_el_read_history (const char *) |
static struct ast_vector_string * | ast_el_strtoarr (char *buf) |
static void | ast_el_write_default_histfile (void) |
static int | ast_el_write_history (const char *) |
static int | ast_makesocket (void) |
int64_t | ast_mark (int i, int startstop) |
static void | ast_network_puts (const char *string) |
write the string to all attached console clients More... | |
static void | ast_network_puts_mutable (const char *string, int level, int sublevel) |
log the string to all attached network console clients More... | |
int | ast_pbx_uuid_get (char *pbx_uuid, int length) |
Retrieve the PBX UUID. More... | |
int64_t | ast_profile (int i, int64_t delta) |
int | ast_register_atexit (void(*func)(void)) |
Register a function to be executed before Asterisk exits. More... | |
int | ast_register_cleanup (void(*func)(void)) |
Register a function to be executed before Asterisk gracefully exits. More... | |
void | ast_register_thread (char *name) |
static void | ast_remotecontrol (char *data) |
void | ast_replace_sigchld (void) |
Replace the SIGCHLD handler. More... | |
static void | ast_run_atexits (int run_cleanups) |
int | ast_safe_execvp (int dualfork, const char *file, char *const argv[]) |
Safely spawn an external program while closing file descriptors. More... | |
int | ast_safe_system (const char *s) |
Safely spawn an OS shell command while closing file descriptors. More... | |
int | ast_set_priority (int pri) |
We set ourselves to a high priority, that we might pre-empt everything else. If your PBX has heavy activity on it, this is a good thing. More... | |
int | ast_shutdown_final (void) |
int | ast_shutting_down (void) |
static int | ast_tryconnect (void) |
void | ast_unregister_atexit (void(*func)(void)) |
Unregister a function registered with ast_register_atexit(). More... | |
void | ast_unregister_thread (void *id) |
void | ast_unreplace_sigchld (void) |
Restore the SIGCHLD handler. More... | |
static void | asterisk_daemon (int isroot, const char *runuser, const char *rungroup) |
static int | can_safely_quit (shutdown_nice_t niceness, int restart) |
static void | canary_exit (void) |
static void * | canary_thread (void *unused) |
static void | check_init (int init_result, const char *name) |
static char * | cli_complete (EditLine *editline, int ch) |
static char * | cli_prompt (EditLine *editline) |
static int | console_print (const char *s) |
static int | console_state_init (void *ptr) |
static void | consolehandler (const char *s) |
static void | env_init (void) |
static int | fdprint (int fd, const char *s) |
static int | fdsend (int fd, const char *s) |
static char * | handle_abort_shutdown (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_bang (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_clear_profile (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_restart_gracefully (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_restart_now (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_restart_when_convenient (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_show_profile (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_show_settings (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
Give an overview of core settings. More... | |
static char * | handle_show_sysinfo (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
Give an overview of system statistics. More... | |
static char * | handle_show_threads (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_stop_gracefully (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_stop_now (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_stop_when_convenient (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_version (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static int | has_priority (void) |
Check whether we were set to high(er) priority. More... | |
static void * | listener (void *unused) |
int | main (int argc, char *argv[]) |
static void | main_atexit (void) |
static void * | monitor_sig_flags (void *unused) |
static void * | netconsole (void *vconsole) |
static int | print_file (int fd, char *desc, const char *filename) |
Print the contents of a file. More... | |
static void | print_intro_message (const char *runuser, const char *rungroup) |
static void | process_histfile (int(*readwrite)(const char *filename)) |
static void | publish_fully_booted (void) |
static void | quit_handler (int num, shutdown_nice_t niceness, int restart) |
static __inline uint64_t | rdtsc (void) |
static int | read_credentials (int fd, char *buffer, size_t size, struct console *con) |
read() function supporting the reception of user credentials. More... | |
static void | read_pjproject_startup_options (void) |
static void | really_quit (int num, shutdown_nice_t niceness, int restart) |
static int | register_atexit (void(*func)(void), int is_cleanup) |
static int | remoteconsolehandler (const char *s) |
static void | run_startup_commands (enum startup_commands_phase phase) |
static pid_t | safe_exec_prep (int dualfork) |
fork and perform other preparations for spawning applications More... | |
static int | safe_exec_wait (pid_t pid) |
wait for spawned application to complete and unreplace sigchld More... | |
static void | send_rasterisk_connect_commands (void) |
static void | set_header (char *outbuf, int maxout, char level) |
static void | set_icon (char *text) |
static int | set_priority_all (int pri) |
Set priority on all known threads. More... | |
static void | set_title (char *text) |
Set an X-term or screen title. More... | |
static int | show_cli_help (void) |
static char * | show_license (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static int | show_version (void) |
static char * | show_warranty (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static int | wait_for_channels_to_die (shutdown_nice_t niceness, int seconds) |
Variables | |
static char * | _argv [256] |
static int | ast_consock = -1 |
struct timeval | ast_lastreloadtime |
pid_t | ast_mainpid |
static int | ast_socket = -1 |
static int | ast_socket_is_sd = 0 |
struct timeval | ast_startuptime |
static struct atexits | atexits = { .first = NULL, .last = NULL, .lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } , } |
static char | canary_filename [128] |
static int | canary_pid = 0 |
static struct sigaction | child_handler |
static struct ast_cli_entry | cli_asterisk [] |
static struct ast_cli_entry | cli_asterisk_shutdown [] |
Shutdown Asterisk CLI commands. More... | |
static struct ast_threadstorage | console_state = { .once = PTHREAD_ONCE_INIT , .key_init = __init_console_state , .custom_init = console_state_init , } |
struct console | consoles [AST_MAX_CONNECTS] |
static pthread_t | consolethread = AST_PTHREADT_NULL |
static EditLine * | el |
static History * | el_hist |
static struct sigaction | hup_handler |
static struct sigaction | ignore_sig_handler |
static const char | license_lines [] |
static pthread_t | lthread |
static pthread_t | mon_sig_flags |
static int | multi_thread_safe |
static struct sigaction | null_sig_handler |
static struct profile_data * | prof_data |
static struct ast_str * | prompt = NULL |
static char | randompool [256] |
static char * | remotehostname |
static int | restartnow |
static unsigned int | safe_system_level = 0 |
Keep track of how many threads are currently trying to wait*() on a child process. More... | |
static ast_mutex_t | safe_system_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } |
static struct sigaction | safe_system_prev_handler |
static int | shutdown_pending |
static shutdown_nice_t | shuttingdown = NOT_SHUTTING_DOWN |
static int | sig_alert_pipe [2] = { -1, -1 } |
struct { | |
unsigned int need_el_end:1 | |
unsigned int need_quit:1 | |
unsigned int need_quit_handler:1 | |
unsigned int need_reload:1 | |
} | sig_flags |
static const char * | startup_commands_phase_str [] |
static struct thread_list | thread_list = { .first = NULL, .last = NULL, .lock = { PTHREAD_RWLOCK_INITIALIZER , NULL, {1, 0} } , } |
static struct sigaction | urg_handler |
static const char | warranty_lines [] |
Top level source file for Asterisk - the Open Source PBX. Implementation of PBX core functions and CLI interface.
Definition in file asterisk.c.
#define AF_LOCAL AF_UNIX |
Definition at line 298 of file asterisk.c.
#define AST_MAX_CONNECTS 128 |
Definition at line 302 of file asterisk.c.
#define ASTERISK_PROMPT "*CLI> " |
Definition at line 2615 of file asterisk.c.
#define CHAR_T_LIBEDIT wchar_t |
Definition at line 2680 of file asterisk.c.
Definition at line 2681 of file asterisk.c.
#define CMD_MATCHESARRAY "_COMMAND MATCHESARRAY \"%s\" \"%s\"" |
#define COPYRIGHT_TAG "Copyright (C) 1999 - 2025, Sangoma Technologies Corporation and others." |
Displayed copyright tag
Definition at line 306 of file asterisk.c.
#define DEFINE_PROFILE_MIN_MAX_VALUES |
Definition at line 901 of file asterisk.c.
#define EL_BUF_SIZE 512 |
#define MAX_HISTORY_COMMAND_LENGTH 256 |
Definition at line 3154 of file asterisk.c.
#define NUM_MSGS 64 |
Definition at line 303 of file asterisk.c.
#define PF_LOCAL PF_UNIX |
Definition at line 299 of file asterisk.c.
#define SHUTDOWN_TIMEOUT 15 /* Seconds */ |
Definition at line 1927 of file asterisk.c.
#define WELCOME_MESSAGE |
Welcome message when starting a CLI interface.
Definition at line 309 of file asterisk.c.
enum shutdown_nice_t |
Enumerator | |
---|---|
NOT_SHUTTING_DOWN | Normal operation |
SHUTTING_DOWN_FINAL | Committed to shutting down. Final phase |
SHUTTING_DOWN | Committed to shutting down. Initial phase |
SHUTDOWN_FAST | Valid values for quit_handler() niceness below. These shutdown/restart levels can be cancelled. Remote console exit right now |
SHUTDOWN_NORMAL | core stop/restart now |
SHUTDOWN_NICE | core stop/restart gracefully |
SHUTDOWN_REALLY_NICE | core stop/restart when convenient |
Definition at line 362 of file asterisk.c.
Enumerator | |
---|---|
STARTUP_COMMANDS_PRE_INIT | |
STARTUP_COMMANDS_PRE_MODULE | |
STARTUP_COMMANDS_FULLY_BOOTED |
Definition at line 3531 of file asterisk.c.
|
static |
Definition at line 1024 of file asterisk.c.
References ast_free, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_atexit::func, and ast_atexit::list.
Referenced by ast_unregister_atexit(), and register_atexit().
|
static |
Definition at line 2221 of file asterisk.c.
|
static |
Definition at line 2149 of file asterisk.c.
References ast_alertpipe_write(), errno, sig_alert_pipe, and sig_flags.
Referenced by asterisk_daemon().
|
static |
Definition at line 2159 of file asterisk.c.
References sig_flags.
Referenced by ast_remotecontrol().
|
static |
Definition at line 1751 of file asterisk.c.
References errno, option_debug, and status.
|
static |
Definition at line 1727 of file asterisk.c.
References _argv, ast_alertpipe_write(), el, errno, restartnow, sig_alert_pipe, and sig_flags.
|
static |
NULL handler so we can collect the child exit status.
Definition at line 1087 of file asterisk.c.
|
static |
Urgent handler.
Called by soft_hangup to interrupt the poll, read, or other system call. We don't actually need to do anything though. Remember: Cannot EVER ast_log from within a signal handler
Definition at line 1718 of file asterisk.c.
int ast_add_profile | ( | const char * | name, |
uint64_t | scale | ||
) |
allocates a counter with a given name and scale.
support for event profiling
Definition at line 805 of file asterisk.c.
References ast_calloc, ast_realloc, ast_strdup, profile_data::e, profile_data::entries, profile_entry::events, profile_entry::mark, profile_data::max_size, name, profile_entry::name, NULL, prof_data, profile_entry::scale, and profile_entry::value.
|
static |
Definition at line 2294 of file asterisk.c.
Referenced by consolehandler(), and remoteconsolehandler().
|
static |
Definition at line 1906 of file asterisk.c.
References ast_mutex_lock, ast_mutex_unlock, NOT_SHUTTING_DOWN, safe_system_lock, shutdown_pending, and shuttingdown.
Referenced by can_safely_quit().
int ast_cancel_shutdown | ( | void | ) |
Cancel an existing shutdown and return to normal operation.
Definition at line 1888 of file asterisk.c.
References ast_mutex_lock, ast_mutex_unlock, NOT_SHUTTING_DOWN, safe_system_lock, SHUTDOWN_FAST, shutdown_pending, and shuttingdown.
Referenced by handle_abort_shutdown().
|
static |
Definition at line 2948 of file asterisk.c.
References ast_get_termcols(), AST_VECTOR_GET, AST_VECTOR_SIZE, and max.
Referenced by cli_complete().
void ast_console_puts | ( | const char * | string | ) |
write the string to the root console, and all attached network console clients
Definition at line 1363 of file asterisk.c.
References ast_network_puts().
void ast_console_puts_mutable | ( | const char * | string, |
int | level | ||
) |
log the string to the root console, and all attached network console clients
log the string to the console, and all attached console clients
Definition at line 1323 of file asterisk.c.
References ast_console_puts_mutable_full().
Referenced by init_logger_chain(), and make_logchannel().
void ast_console_puts_mutable_full | ( | const char * | message, |
int | level, | ||
int | sublevel | ||
) |
log the string to the console, and all attached console clients
message | The message to write to the console |
sublevel | If the log level supports it, the sub-level of the message |
level | The log level of the message |
Definition at line 1330 of file asterisk.c.
References ast_network_puts_mutable(), ast_opt_console, AST_PTHREADT_NULL, console_print(), and consolethread.
Referenced by ast_console_puts_mutable(), and logger_print_normal().
void ast_console_toggle_loglevel | ( | int | fd, |
int | level, | ||
int | state | ||
) |
enable or disable a logging level to a specified console
enables or disables logging of a specified level to the console fd specifies the index of the console receiving the level change level specifies the index of the logging level being toggled state indicates whether logging will be on or off (0 for off, 1 for on)
Definition at line 1258 of file asterisk.c.
References AST_MAX_CONNECTS, consoles, console::levels, and NUMLOGLEVELS.
Referenced by handle_logger_set_level().
void ast_console_toggle_mute | ( | int | fd, |
int | silent | ||
) |
mute or unmute a console from logging
Definition at line 1281 of file asterisk.c.
References ast_cli(), AST_MAX_CONNECTS, consoles, and console::mute.
Referenced by handle_logger_mute().
|
static |
Definition at line 3156 of file asterisk.c.
References ast_el_initialize(), ast_strdupa, ast_strip(), buf, el, el_hist, MAX_HISTORY_COMMAND_LENGTH, and NULL.
Referenced by consolehandler(), and remoteconsolehandler().
|
static |
Definition at line 3101 of file asterisk.c.
References cli_complete(), cli_prompt(), el, el_hist, and NULL.
Referenced by ast_el_add_history(), ast_el_read_history(), ast_el_write_history(), ast_remotecontrol(), and asterisk_daemon().
|
static |
Definition at line 2687 of file asterisk.c.
References ast_consock, ast_opt_exec, ast_opt_reconnect, ast_poll, ast_tryconnect(), buf, c, CHAR_TO_LIBEDIT, console_print(), EL_BUF_SIZE, errno, max, quit_handler(), send_rasterisk_connect_commands(), SHUTDOWN_FAST, sig_flags, term_quit(), and WELCOME_MESSAGE.
Referenced by ast_remotecontrol(), and asterisk_daemon().
|
static |
Definition at line 3231 of file asterisk.c.
References ast_el_read_history(), and process_histfile().
Referenced by ast_remotecontrol(), and asterisk_daemon().
|
static |
Definition at line 3188 of file asterisk.c.
References ast_el_initialize(), el, el_hist, and NULL.
Referenced by ast_el_read_default_histfile().
|
static |
Definition at line 2914 of file asterisk.c.
References ast_calloc, AST_CLI_COMPLETE_EOF, ast_free, ast_strdup, AST_VECTOR_APPEND, AST_VECTOR_CALLBACK_VOID, AST_VECTOR_PTR_FREE, AST_VECTOR_SIZE, buf, NULL, and strsep().
Referenced by cli_complete().
|
static |
Definition at line 3236 of file asterisk.c.
References ast_el_write_history(), and process_histfile().
Referenced by really_quit().
|
static |
Definition at line 3178 of file asterisk.c.
References ast_el_initialize(), el, el_hist, and NULL.
Referenced by ast_el_write_default_histfile().
|
static |
Definition at line 1605 of file asterisk.c.
References AF_LOCAL, ast_config_AST_CTL_GROUP, ast_config_AST_CTL_OWNER, ast_config_AST_CTL_PERMISSIONS, ast_config_AST_SOCKET, ast_copy_string(), ast_log, AST_MAX_CONNECTS, ast_pthread_create_background, ast_sd_get_fd_un(), ast_socket, ast_socket_is_sd, ast_strlen_zero(), consoles, errno, console::fd, listener(), LOG_WARNING, lthread, NULL, and PF_LOCAL.
Referenced by asterisk_daemon().
int64_t ast_mark | ( | int | i, |
int | startstop | ||
) |
Definition at line 880 of file asterisk.c.
References profile_data::e, profile_data::entries, profile_entry::events, profile_entry::mark, prof_data, rdtsc(), profile_entry::scale, and profile_entry::value.
|
static |
write the string to all attached console clients
Definition at line 1347 of file asterisk.c.
References AST_MAX_CONNECTS, consoles, and fdprint().
Referenced by ast_console_puts().
|
static |
log the string to all attached network console clients
Definition at line 1304 of file asterisk.c.
References __LOG_VERBOSE, AST_MAX_CONNECTS, consoles, fdprint(), levels, and option_verbose.
Referenced by ast_console_puts_mutable_full().
int ast_pbx_uuid_get | ( | char * | pbx_uuid, |
int | length | ||
) |
Retrieve the PBX UUID.
pbx_uuid | A buffer of at least AST_UUID_STR_LEN (36 + 1) size to receive the UUID |
length | The buffer length |
Definition at line 979 of file asterisk.c.
References ast_db_get().
Referenced by asterisk_daemon(), and handle_show_settings().
int64_t ast_profile | ( | int | i, |
int64_t | delta | ||
) |
Definition at line 839 of file asterisk.c.
References profile_data::e, profile_data::entries, profile_entry::events, prof_data, profile_entry::scale, and profile_entry::value.
int ast_register_atexit | ( | void(*)(void) | func | ) |
Register a function to be executed before Asterisk exits.
func | The callback function to use. |
0 | on success. |
-1 | on error. |
Definition at line 1057 of file asterisk.c.
References ast_atexit::func, and register_atexit().
Referenced by asterisk_daemon().
int ast_register_cleanup | ( | void(*)(void) | func | ) |
Register a function to be executed before Asterisk gracefully exits.
If Asterisk is immediately shutdown (core stop now, or sending the TERM signal), the callback is not run. When the callbacks are run, they are run in sequence with ast_register_atexit() callbacks, in the reverse order of registration.
func | The callback function to use. |
0 | on success. |
-1 | on error. |
Definition at line 1062 of file asterisk.c.
References ast_atexit::func, and register_atexit().
Referenced by asterisk_daemon().
void ast_register_thread | ( | char * | name | ) |
Definition at line 420 of file asterisk.c.
References ast_assert, ast_calloc, ast_get_tid(), AST_RWLIST_INSERT_HEAD, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, multi_thread_safe, and name.
Referenced by dummy_start().
|
static |
Definition at line 3241 of file asterisk.c.
References __remote_quit_handler(), ast_alloca, ast_consock, ast_el_initialize(), ast_el_read_char(), ast_el_read_default_histfile(), ast_init_logger_for_socket_console(), ast_log, ast_opt_exec, ast_poll, ast_strlen_zero(), ast_term_init(), ast_verbose(), buf, el, el_hist, errno, hostname, LOG_ERROR, LOG_WARNING, NULL, prefix, remoteconsolehandler(), remotehostname, send_rasterisk_connect_commands(), sig_flags, strsep(), term_end(), and version.
Referenced by main().
void ast_replace_sigchld | ( | void | ) |
Replace the SIGCHLD handler.
Normally, Asterisk has a SIGCHLD handler that is cleaning up all zombie processes from forking elsewhere in Asterisk. However, if you want to wait*() on the process to retrieve information about it's exit status, then this signal handler needs to be temporarily replaced.
Code that executes this function must call ast_unreplace_sigchld() after it is finished doing the wait*().
Definition at line 1107 of file asterisk.c.
References ast_mutex_lock, ast_mutex_unlock, null_sig_handler, safe_system_level, safe_system_lock, and safe_system_prev_handler.
Referenced by safe_exec_prep().
|
static |
Definition at line 1010 of file asterisk.c.
References ast_free, AST_LIST_LOCK, AST_LIST_REMOVE_HEAD, AST_LIST_UNLOCK, ast_atexit::func, ast_atexit::is_cleanup, and ast_atexit::list.
Referenced by check_init(), and really_quit().
int ast_safe_execvp | ( | int | dualfork, |
const char * | file, | ||
char *const | argv[] | ||
) |
Safely spawn an external program while closing file descriptors.
dualfork | Non-zero to simulate running the program in the background by forking twice. The option provides similar functionality to the '&' in the OS shell command "cmd &". The option allows Asterisk to run a reaper loop to watch the first fork which immediately exits after spaning the second fork. The actual program is run in the second fork. |
file | execvp(file, argv) file parameter |
argv | execvp(file, argv) argv parameter |
Definition at line 1229 of file asterisk.c.
References make_ari_stubs::file, safe_exec_prep(), and safe_exec_wait().
Referenced by run_externnotify().
int ast_safe_system | ( | const char * | s | ) |
Safely spawn an OS shell command while closing file descriptors.
s | - OS shell command string to execute. |
Definition at line 1242 of file asterisk.c.
References NULL, safe_exec_prep(), and safe_exec_wait().
Referenced by consolehandler(), and remoteconsolehandler().
int ast_set_priority | ( | int | pri | ) |
We set ourselves to a high priority, that we might pre-empt everything else. If your PBX has heavy activity on it, this is a good thing.
Provided by asterisk.c
Definition at line 1848 of file asterisk.c.
References ast_log, ast_verb, LOG_WARNING, sched_setscheduler, and setpriority.
Referenced by app_exec(), asterisk_daemon(), launch_script(), main(), mp3play(), safe_exec_prep(), send_waveform_to_fd(), set_priority_all(), and spawn_mp3().
int ast_shutdown_final | ( | void | ) |
The server is releasing resources and unloading modules. It won't be long now.
Definition at line 1878 of file asterisk.c.
References SHUTTING_DOWN_FINAL, and shuttingdown.
Referenced by httpd_process_request(), load_resource(), send_notify(), session_inv_on_media_update(), session_inv_on_redirected(), session_inv_on_rx_offer(), session_inv_on_state_changed(), session_inv_on_tsx_state_changed(), and unload_module().
int ast_shutting_down | ( | void | ) |
The server is preventing new channel creation in preparation for shutdown and may actively be releasing resources. The shutdown process may be canceled by ast_cancel_shutdown() if it is not too late.
Definition at line 1883 of file asterisk.c.
References shutdown_pending.
Referenced by __ast_channel_alloc_ap(), ast_cli_command_full(), ast_unregister_translator(), confbridge_exec(), options_on_rx_request(), and process_message().
|
static |
Definition at line 1691 of file asterisk.c.
References AF_LOCAL, ast_config_AST_SOCKET, ast_consock, ast_copy_string(), errno, and PF_LOCAL.
Referenced by ast_el_read_char(), and main().
void ast_unregister_atexit | ( | void(*)(void) | func | ) |
Unregister a function registered with ast_register_atexit().
func | The callback function to unregister. |
Definition at line 1067 of file asterisk.c.
References __ast_unregister_atexit(), AST_LIST_LOCK, AST_LIST_UNLOCK, and ast_atexit::func.
Referenced by unload_module().
void ast_unregister_thread | ( | void * | id | ) |
Definition at line 436 of file asterisk.c.
References ast_free, AST_RWLIST_REMOVE_CURRENT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, and AST_RWLIST_WRLOCK.
Referenced by dummy_start().
void ast_unreplace_sigchld | ( | void | ) |
Restore the SIGCHLD handler.
This function is called after a call to ast_replace_sigchld. It restores the SIGCHLD handler that cleans up any zombie processes.
Definition at line 1122 of file asterisk.c.
References ast_assert, ast_mutex_lock, ast_mutex_unlock, NULL, safe_system_level, safe_system_lock, and safe_system_prev_handler.
Referenced by safe_exec_wait().
|
static |
Definition at line 4107 of file asterisk.c.
References __quit_handler(), aco_init(), app_init(), ARRAY_LEN, ast_alaw_init(), ast_alertpipe_init(), ast_aoc_cli_init(), ast_autoservice_init(), ast_bridging_init(), ast_bucket_init(), ast_builtins_init(), ast_channels_init(), ast_clear_flag, ast_cli_channels_init(), ast_cli_perms_init(), ast_cli_register_multiple, ast_close_fds_above_n(), ast_codec_builtin_init(), ast_codec_init(), ast_config_AST_PID, ast_config_AST_RUN_DIR, ast_config_AST_SBIN_DIR, ast_copy_string(), ast_db_put(), ast_device_state_engine_init(), ast_dns_system_resolver_init(), ast_el_initialize(), ast_el_read_char(), ast_el_read_default_histfile(), ast_endpoint_init(), ast_endpoint_stasis_init(), ast_fd_init(), ast_file_init(), ast_format_cache_init(), ast_format_init(), ast_image_init(), ast_json_init(), ast_lastreloadtime, ast_local_init(), ast_mainpid, ast_makesocket(), ast_media_cache_init(), ast_msg_init(), ast_named_locks_init(), ast_opt_always_fork, ast_opt_console, AST_OPT_FLAG_FULLY_BOOTED, AST_OPT_FLAG_HIGH_PRIORITY, ast_opt_high_priority, ast_opt_no_fork, ast_options, ast_parking_stasis_init(), ast_pbx_init(), ast_pbx_uuid_get(), ast_pickup_init(), ast_pj_init(), ast_presence_state_engine_init(), ast_process_pending_reloads(), ast_pthread_create_detached, ast_refer_init(), ast_register_atexit(), ast_register_cleanup(), ast_rtp_engine_init(), ast_sd_notify(), ast_security_stasis_init(), ast_set_flag, ast_set_priority(), ast_sorcery_init(), ast_ssl_init(), ast_startuptime, ast_stasis_system_init(), ast_stun_init(), ast_term_init(), ast_test_init(), ast_timing_init(), ast_tps_init(), ast_translate_init(), ast_tvnow(), ast_ulaw_init(), ast_utf8_init(), ast_utils_init(), ast_uuid_generate_str(), ast_uuid_init(), AST_UUID_STR_LEN, ast_verb, ast_xmldoc_load_documentation(), astdb_init(), astobj2_init(), buf, callerid_init(), canary_exit(), canary_filename, canary_pid, canary_thread(), check_init(), cli_asterisk, cli_asterisk_shutdown, COLOR_BRGREEN, COLORIZE, COLORIZE_FMT, consolehandler(), consolethread, devstate_init(), dns_core_init(), dnsmgr_start_refresh(), el, el_hist, errno, has_priority(), hostname, hup_handler, ignore_sig_handler, init_logger(), load_astmm_phase_1(), load_astmm_phase_2(), load_modules(), load_pbx(), load_pbx_app(), load_pbx_builtins(), load_pbx_functions_cli(), load_pbx_hangup_handler(), load_pbx_switch(), load_pbx_variables(), logger_queue_start(), main_atexit(), MAXHOSTNAMELEN, mon_sig_flags, monitor_sig_flags(), multi_thread_safe, mwi_init(), NULL, PATH_MAX, print_intro_message(), publish_fully_booted(), quit_handler(), randompool, read_pjproject_startup_options(), register_config_cli(), run_startup_commands(), set_icon(), set_title(), SHUTDOWN_FAST, sig_alert_pipe, sig_flags, STARTUP_COMMANDS_FULLY_BOOTED, STARTUP_COMMANDS_PRE_INIT, STARTUP_COMMANDS_PRE_MODULE, stasis_init(), tdd_init(), term_end(), threadstorage_init(), and urg_handler.
Referenced by main().
|
static |
Definition at line 1970 of file asterisk.c.
References ast_begin_shutdown(), ast_cdr_engine_term(), ast_msg_shutdown(), ast_mutex_lock, ast_mutex_unlock, ast_opt_console, ast_softhangup_all(), ast_verb, ast_verbose(), NOT_SHUTTING_DOWN, safe_system_lock, SHUTDOWN_NICE, SHUTDOWN_NORMAL, SHUTDOWN_REALLY_NICE, SHUTDOWN_TIMEOUT, SHUTTING_DOWN, SHUTTING_DOWN_FINAL, shuttingdown, and wait_for_channels_to_die().
Referenced by quit_handler().
|
static |
Definition at line 3522 of file asterisk.c.
References canary_pid, and status.
Referenced by asterisk_daemon().
|
static |
Definition at line 3493 of file asterisk.c.
References ast_log, ast_tvnow(), canary_filename, LOG_WARNING, NULL, and set_priority_all().
Referenced by asterisk_daemon().
|
inlinestatic |
Definition at line 4094 of file asterisk.c.
References ast_is_logger_initialized(), ast_log, ast_run_atexits(), LOG_ERROR, name, and term_quit().
Referenced by asterisk_daemon().
|
static |
Definition at line 2975 of file asterisk.c.
References ast_asprintf, AST_CLI_COMPLETE_EOF, ast_cli_completion_vector(), ast_cli_display_match_list(), ast_consock, ast_el_strtoarr(), ast_free, ast_opt_remote, ast_realloc, ast_strlen_zero(), AST_VECTOR_CALLBACK_VOID, AST_VECTOR_GET, AST_VECTOR_PTR_FREE, AST_VECTOR_SIZE, CMD_MATCHESARRAY, fdsend(), if(), and len().
Referenced by ast_el_initialize().
|
static |
Definition at line 2788 of file asterisk.c.
References ast_config_AST_SYSTEM_NAME, ast_localtime(), ast_opt_remote, ast_str_append(), ast_str_buffer(), ast_str_create, ast_str_reset(), ast_str_set(), ast_strftime(), ast_term_color_code(), ast_tvnow(), ASTERISK_PROMPT, COLOR_BLACK, COLOR_WHITE, getloadavg(), hostname, MAXHOSTNAMELEN, NULL, prompt, and remotehostname.
Referenced by ast_el_initialize().
|
static |
Definition at line 2223 of file asterisk.c.
References ast_strlen_zero(), ast_threadstorage_get(), c, console_state, option_verbose, prefix, set_header(), VERBOSE_HASMAGIC, and VERBOSE_MAGIC2LEVEL.
Referenced by ast_console_puts_mutable_full(), and ast_el_read_char().
|
static |
Definition at line 2214 of file asterisk.c.
|
static |
Definition at line 2305 of file asterisk.c.
References ast_all_zeros(), ast_el_add_history(), ast_safe_system(), and term_end().
Referenced by asterisk_daemon().
|
static |
Definition at line 3574 of file asterisk.c.
References ast_build_date, ast_build_hostname, ast_build_kernel, ast_build_machine, ast_build_os, ast_build_user, ast_config_AST_SYSTEM_NAME, ast_get_version(), and setenv().
Referenced by main().
|
static |
Definition at line 1081 of file asterisk.c.
Referenced by ast_network_puts(), ast_network_puts_mutable(), listener(), and netconsole().
|
static |
Definition at line 1075 of file asterisk.c.
Referenced by cli_complete(), and send_rasterisk_connect_commands().
|
static |
Definition at line 2497 of file asterisk.c.
References a, ast_cli_entry::args, ast_cancel_shutdown(), ast_cli_allow_at_shutdown(), CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, NULL, and ast_cli_entry::usage.
|
static |
Definition at line 2520 of file asterisk.c.
References CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, NULL, and ast_cli_entry::usage.
|
static |
Definition at line 949 of file asterisk.c.
References CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, DEFINE_PROFILE_MIN_MAX_VALUES, profile_data::e, profile_entry::events, max, min, profile_entry::name, NULL, prof_data, ast_cli_entry::usage, and profile_entry::value.
|
static |
Definition at line 2455 of file asterisk.c.
References a, ast_cli_entry::args, ast_cli_allow_at_shutdown(), CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, NULL, quit_handler(), SHUTDOWN_NICE, and ast_cli_entry::usage.
|
static |
Definition at line 2434 of file asterisk.c.
References a, ast_cli_entry::args, ast_cli_allow_at_shutdown(), CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, NULL, quit_handler(), SHUTDOWN_NORMAL, and ast_cli_entry::usage.
|
static |
Definition at line 2476 of file asterisk.c.
References a, ast_cli_entry::args, ast_cli(), ast_cli_allow_at_shutdown(), CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, NULL, quit_handler(), SHUTDOWN_REALLY_NICE, and ast_cli_entry::usage.
|
static |
Definition at line 914 of file asterisk.c.
References a, ast_cli(), CLI_GENERATE, CLI_INIT, CLI_SUCCESS, DEFINE_PROFILE_MIN_MAX_VALUES, profile_data::e, profile_data::entries, profile_entry::events, max, profile_data::max_size, min, profile_entry::name, NULL, prof_data, profile_entry::scale, and profile_entry::value.
|
static |
Give an overview of core settings.
Definition at line 473 of file asterisk.c.
References a, ast_active_channels(), ast_build_date, ast_build_kernel, ast_build_machine, ast_build_os, ast_build_user, ast_cdr_is_enabled(), ast_cli(), ast_config_AST_AGI_DIR, ast_config_AST_CACHE_DIR, ast_config_AST_CONFIG_DIR, ast_config_AST_CONFIG_FILE, ast_config_AST_DATA_DIR, ast_config_AST_DB, ast_config_AST_KEY_DIR, ast_config_AST_LOG_DIR, ast_config_AST_MODULE_DIR, ast_config_AST_PID, ast_config_AST_RUN_DIR, ast_config_AST_RUN_GROUP, ast_config_AST_RUN_USER, ast_config_AST_SPOOL_DIR, ast_config_AST_SYSTEM_NAME, ast_config_AST_VAR_DIR, ast_defaultlanguage, ast_eid_default, ast_eid_to_str(), ast_get_build_opts(), ast_get_build_opts_all(), ast_get_version(), ast_language_is_prefix, ast_lastreloadtime, ast_localtime(), ast_manager_check_enabled(), ast_opt_cache_media_frames, ast_opt_dump_core, AST_OPT_FLAG_EXEC_INCLUDES, AST_OPT_FLAG_GENERIC_PLC, AST_OPT_FLAG_GENERIC_PLC_ON_EQUAL_CODECS, AST_OPT_FLAG_TRANSCODE_VIA_SLIN, AST_OPT_FLAG_TRANSMIT_SILENCE, ast_opt_hide_messaging_ami_events, ast_opt_sounds_search_custom, ast_option_maxcalls, ast_option_maxfiles, ast_option_maxload, ast_option_rtpptdynamic, ast_option_rtpusedynamic, ast_options, ast_pbx_uuid_get(), ast_realtime_enabled(), AST_RTP_MAX_PT, AST_RTP_PT_FIRST_DYNAMIC, AST_RTP_PT_LAST_REASSIGN, ast_startuptime, ast_strftime(), ast_test_flag, AST_UUID_STR_LEN, ast_verb_console_get(), ast_webmanager_check_enabled(), buf, CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, errno, NULL, option_debug, option_dtmfminduration, option_minmemfree, option_trace, option_verbose, PATH_MAX, print_file(), S_OR, and ast_cli_entry::usage.
|
static |
Give an overview of system statistics.
Definition at line 676 of file asterisk.c.
References a, ast_cli(), CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, len(), NULL, and ast_cli_entry::usage.
|
static |
Definition at line 610 of file asterisk.c.
References a, ast_cli(), AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, NULL, and ast_cli_entry::usage.
|
static |
Definition at line 2392 of file asterisk.c.
References a, ast_cli_entry::args, ast_cli_allow_at_shutdown(), CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, NULL, quit_handler(), SHUTDOWN_NICE, and ast_cli_entry::usage.
|
static |
Definition at line 2372 of file asterisk.c.
References a, ast_cli_entry::args, ast_cli_allow_at_shutdown(), CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, NULL, quit_handler(), SHUTDOWN_NORMAL, and ast_cli_entry::usage.
|
static |
Definition at line 2413 of file asterisk.c.
References a, ast_cli_entry::args, ast_cli(), ast_cli_allow_at_shutdown(), CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, NULL, quit_handler(), SHUTDOWN_REALLY_NICE, and ast_cli_entry::usage.
|
static |
Definition at line 2351 of file asterisk.c.
References a, ast_build_date, ast_build_hostname, ast_build_machine, ast_build_os, ast_build_user, ast_cli(), ast_get_version(), CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, NULL, and ast_cli_entry::usage.
|
static |
Check whether we were set to high(er) priority.
Definition at line 1785 of file asterisk.c.
Referenced by ast_ari_validate_dialplan_cep(), and asterisk_daemon().
|
static |
Definition at line 1525 of file asterisk.c.
References AF_LOCAL, ast_fd_set_flags, ast_log, AST_MAX_CONNECTS, ast_opt_hide_connect, ast_poll, ast_pthread_create_detached_background, ast_socket, ast_verb, consoles, errno, console::fd, fdprint(), console::gid, len(), LOG_ERROR, LOG_WARNING, console::mute, netconsole(), NULL, console::option_verbose, and console::uid.
Referenced by __allocate_taskprocessor(), ast_makesocket(), ast_taskprocessor_create_with_listener(), ast_taskprocessor_get(), ast_taskprocessor_listener_alloc(), ast_taskprocessor_listener_get_tps(), ast_taskprocessor_listener_get_user_data(), AST_TEST_DEFINE(), ast_threadpool_create(), ast_threadpool_listener_alloc(), ast_threadpool_listener_get_user_data(), ast_threadpool_serializer_group(), default_listener_pvt_dtor(), default_listener_shutdown(), default_listener_start(), default_task_pushed(), default_tps_processing_function(), listener_check(), listener_shutdown(), serializer_shutdown(), serializer_task_pushed(), taskprocessor_listener_dtor(), test_emptied(), test_shutdown(), test_state_changed(), test_task_pushed(), threadpool_tps_emptied(), threadpool_tps_shutdown(), threadpool_tps_task_pushed(), and wait_for_task_pushed().
int main | ( | int | argc, |
char * | argv[] | ||
) |
Check for options
Definition at line 3604 of file asterisk.c.
References _argv, ARRAY_LEN, ast_clear_flag, ast_config_AST_RUN_DIR, ast_config_AST_RUN_GROUP, ast_config_AST_RUN_USER, ast_config_AST_SOCKET, ast_FD_SETSIZE, ast_FDMAX, ast_free, ast_language_is_prefix, ast_log, ast_mainpid, ast_opt_always_fork, ast_opt_console, ast_opt_dump_core, ast_opt_exec, AST_OPT_FLAG_ALWAYS_FORK, AST_OPT_FLAG_CACHE_RECORD_FILES, AST_OPT_FLAG_CONSOLE, AST_OPT_FLAG_DUMP_CORE, AST_OPT_FLAG_EXEC, AST_OPT_FLAG_EXEC_INCLUDES, AST_OPT_FLAG_FORCE_BLACK_BACKGROUND, AST_OPT_FLAG_HIGH_PRIORITY, AST_OPT_FLAG_INIT_KEYS, AST_OPT_FLAG_LIGHT_BACKGROUND, AST_OPT_FLAG_MUTE, AST_OPT_FLAG_NO_COLOR, AST_OPT_FLAG_NO_FORK, AST_OPT_FLAG_QUIET, AST_OPT_FLAG_RECONNECT, AST_OPT_FLAG_REMOTE, AST_OPT_FLAG_TIMESTAMP, ast_opt_high_priority, ast_opt_no_fork, ast_opt_remote, ast_option_maxcalls, ast_option_maxload, ast_options, ast_remotecontrol(), ast_sd_get_fd_un(), ast_select(), ast_set_flag, ast_set_priority(), ast_socket_is_sd, ast_strdup, ast_strlen_zero(), ast_term_init(), ast_test_flag, ast_tryconnect(), ast_verb_sys_level, asterisk_daemon(), c, child_handler, env_init(), errno, FD_SET, FD_ZERO, load_asterisk_conf(), LOG_WARNING, multi_thread_safe, NULL, option_debug, option_minmemfree, option_verbose, PATH_MAX, print_intro_message(), quit_handler(), RAII_VAR, set_asterisk_conf_path(), set_socket_path(), show_cli_help(), show_version(), SHUTDOWN_FAST, term_end(), and term_quit().
|
static |
Definition at line 3599 of file asterisk.c.
References ARRAY_LEN, ast_cli_unregister_multiple(), and cli_asterisk.
Referenced by asterisk_daemon().
|
static |
Definition at line 3468 of file asterisk.c.
References ast_alertpipe_read(), ast_module_reload(), ast_poll, AST_PTHREADT_NULL, consolethread, NULL, quit_handler(), SHUTDOWN_NORMAL, sig_alert_pipe, and sig_flags.
Referenced by asterisk_daemon().
|
static |
Definition at line 1435 of file asterisk.c.
References ast_cli_command_multiple_full(), ast_copy_string(), ast_get_version(), ast_log, ast_mainpid, ast_opt_hide_connect, ast_poll, ast_verb, ast_verb_console_register(), ast_verb_console_unregister(), errno, console::fd, fdprint(), console::gid, hostname, inbuf(), LOG_ERROR, LOG_WARNING, MAXHOSTNAMELEN, NULL, console::option_verbose, console::p, read_credentials(), and console::uid.
Referenced by listener().
|
static |
Print the contents of a file.
Definition at line 456 of file asterisk.c.
References ast_cli(), c, and desc.
Referenced by handle_show_settings().
|
static |
Definition at line 3586 of file asterisk.c.
References ast_opt_console, ast_opt_exec, ast_opt_remote, ast_verbose(), option_verbose, and WELCOME_MESSAGE.
Referenced by asterisk_daemon(), and main().
|
static |
Definition at line 3204 of file asterisk.c.
References ast_asprintf, ast_free, ast_log, ast_strlen_zero(), LOG_ERROR, name, and NULL.
Referenced by ast_el_read_default_histfile(), and ast_el_write_default_histfile().
|
static |
Definition at line 984 of file asterisk.c.
References ast_json_pack(), ast_json_unref(), ast_lastreloadtime, ast_manager_publish_event(), ast_startuptime, ast_tvnow(), ast_tvsub(), and EVENT_FLAG_SYSTEM.
Referenced by asterisk_daemon().
|
static |
Definition at line 1918 of file asterisk.c.
References can_safely_quit(), and really_quit().
Referenced by ast_el_read_char(), asterisk_daemon(), handle_restart_gracefully(), handle_restart_now(), handle_restart_when_convenient(), handle_stop_gracefully(), handle_stop_now(), handle_stop_when_convenient(), main(), monitor_sig_flags(), and remoteconsolehandler().
|
static |
|
static |
read() function supporting the reception of user credentials.
fd | Socket file descriptor. |
buffer | Receive buffer. |
size | 'buffer' size. |
con | Console structure to set received credentials |
-1 | on error |
the | number of bytes received on success. |
Definition at line 1385 of file asterisk.c.
References console::gid, len(), result, and console::uid.
Referenced by netconsole().
|
static |
Definition at line 3434 of file asterisk.c.
References ast_config_destroy(), ast_config_load2(), ast_false(), ast_option_pjproject_cache_pools, ast_option_pjproject_log_level, ast_variable_browse(), CONFIG_FLAG_NOCACHE, CONFIG_FLAG_NOREALTIME, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEUNCHANGED, DEFAULT_PJ_LOG_MAX_LEVEL, DEFAULT_PJPROJECT_CACHE_POOLS, MAX_PJ_LOG_MAX_LEVEL, ast_variable::name, ast_variable::next, and ast_variable::value.
Referenced by asterisk_daemon().
|
static |
Called when exiting is certain.
Definition at line 2053 of file asterisk.c.
References _argv, ast_active_channels(), ast_alertpipe_close(), ast_config_AST_PID, ast_config_AST_SOCKET, ast_consock, ast_debug, ast_el_write_default_histfile(), ast_json_pack(), ast_json_unref(), ast_manager_publish_event(), ast_opt_console, ast_opt_exec, ast_opt_remote, AST_PTHREADT_NULL, ast_run_atexits(), ast_sd_notify(), ast_socket, ast_socket_is_sd, ast_verb, clean_time_zones(), close_logger(), consolethread, el, el_hist, EVENT_FLAG_SYSTEM, lthread, modules_shutdown(), NULL, restartnow, SHUTDOWN_NICE, sig_alert_pipe, sig_flags, and term_quit().
Referenced by quit_handler().
|
static |
Definition at line 1038 of file asterisk.c.
References __ast_unregister_atexit(), ast_calloc, AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_UNLOCK, ast_atexit::func, ast_atexit::is_cleanup, and ast_atexit::list.
Referenced by ast_register_atexit(), and ast_register_cleanup().
|
static |
Definition at line 2323 of file asterisk.c.
References ast_all_zeros(), ast_el_add_history(), ast_safe_system(), quit_handler(), and SHUTDOWN_FAST.
Referenced by ast_remotecontrol().
|
static |
Definition at line 3544 of file asterisk.c.
References ast_config_destroy(), ast_config_load2(), ast_in_delimited_string(), ast_str_to_lower(), ast_strdupa, ast_variable_browse(), CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEMISSING, CONFIG_STATUS_FILEUNCHANGED, ast_variable::name, ast_variable::next, startup_commands_phase_str, ast_variable::value, and value.
Referenced by asterisk_daemon().
|
static |
fork and perform other preparations for spawning applications
Definition at line 1142 of file asterisk.c.
References ast_close_fds_above_n(), ast_log, ast_opt_high_priority, ast_replace_sigchld(), ast_set_priority(), errno, and LOG_WARNING.
Referenced by ast_safe_execvp(), and ast_safe_system().
|
static |
wait for spawned application to complete and unreplace sigchld
Definition at line 1203 of file asterisk.c.
References ast_unreplace_sigchld(), errno, status, WEXITSTATUS, and WIFEXITED.
Referenced by ast_safe_execvp(), and ast_safe_system().
|
static |
Definition at line 2651 of file asterisk.c.
References ast_consock, ast_opt_mute, buf, fdsend(), option_debug, and option_verbose.
Referenced by ast_el_read_char(), and ast_remotecontrol().
|
static |
Definition at line 2164 of file asterisk.c.
References ast_localtime(), ast_logger_get_dateformat(), ast_opt_timestamp, ast_strftime(), ast_term_color(), ast_term_reset(), ast_tvnow(), COLOR_GRAY, NULL, VERBOSE_PREFIX_1, VERBOSE_PREFIX_10, VERBOSE_PREFIX_2, VERBOSE_PREFIX_3, VERBOSE_PREFIX_4, VERBOSE_PREFIX_5, VERBOSE_PREFIX_6, VERBOSE_PREFIX_7, VERBOSE_PREFIX_8, and VERBOSE_PREFIX_9.
Referenced by console_print().
|
static |
Definition at line 1778 of file asterisk.c.
References text.
Referenced by asterisk_daemon().
|
static |
Set priority on all known threads.
Definition at line 1805 of file asterisk.c.
References ast_log, AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_set_priority(), ast_verb, LOG_WARNING, and sched_setscheduler.
Referenced by canary_thread().
|
static |
Set an X-term or screen title.
Definition at line 1772 of file asterisk.c.
References text.
Referenced by asterisk_daemon().
|
static |
Definition at line 3395 of file asterisk.c.
References ast_get_version(), and COPYRIGHT_TAG.
Referenced by main().
|
static |
Definition at line 2597 of file asterisk.c.
References a, ast_cli(), CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, license_lines, NULL, and ast_cli_entry::usage.
|
static |
|
static |
Definition at line 2560 of file asterisk.c.
References a, ast_cli(), CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, NULL, ast_cli_entry::usage, and warranty_lines.
|
static |
Definition at line 1940 of file asterisk.c.
References ast_undestroyed_channels(), and shuttingdown.
Referenced by can_safely_quit().
|
static |
Definition at line 360 of file asterisk.c.
Referenced by _hup_handler(), main(), and really_quit().
|
static |
UNIX Socket for controlling another asterisk
Definition at line 320 of file asterisk.c.
Referenced by ast_el_read_char(), ast_remotecontrol(), ast_tryconnect(), cli_complete(), really_quit(), and send_rasterisk_connect_commands().
struct timeval ast_lastreloadtime |
Definition at line 343 of file asterisk.c.
Referenced by action_corestatus(), action_login(), ast_ari_asterisk_get_info(), ast_module_reload(), ast_var_Config(), asterisk_daemon(), get_last_reload_cb(), handle_show_settings(), handle_showuptime(), and publish_fully_booted().
pid_t ast_mainpid |
Definition at line 321 of file asterisk.c.
Referenced by asterisk_daemon(), main(), netconsole(), safe_append(), and scan_service().
|
static |
UNIX Socket for allowing remote control
Definition at line 318 of file asterisk.c.
Referenced by ast_makesocket(), listener(), and really_quit().
|
static |
Is socket activation responsible for ast_socket?
Definition at line 319 of file asterisk.c.
Referenced by ast_makesocket(), main(), and really_quit().
struct timeval ast_startuptime |
Definition at line 342 of file asterisk.c.
Referenced by action_corestatus(), action_login(), ast_ari_asterisk_get_info(), ast_var_Config(), asterisk_daemon(), get_core_uptime_cb(), handle_show_settings(), handle_showcalls(), handle_showuptime(), and publish_fully_booted().
|
static |
|
static |
Definition at line 393 of file asterisk.c.
Referenced by asterisk_daemon(), and canary_thread().
|
static |
Definition at line 392 of file asterisk.c.
Referenced by asterisk_daemon(), and canary_exit().
|
static |
Definition at line 1766 of file asterisk.c.
Referenced by main().
|
static |
Definition at line 2634 of file asterisk.c.
Referenced by asterisk_daemon(), and main_atexit().
|
static |
Shutdown Asterisk CLI commands.
Definition at line 2625 of file asterisk.c.
Referenced by asterisk_daemon().
|
static |
Definition at line 2221 of file asterisk.c.
Referenced by console_print().
struct console consoles[AST_MAX_CONNECTS] |
Definition at line 349 of file asterisk.c.
Referenced by ast_console_toggle_loglevel(), ast_console_toggle_mute(), ast_makesocket(), ast_network_puts(), ast_network_puts_mutable(), and listener().
|
static |
Definition at line 390 of file asterisk.c.
Referenced by ast_console_puts_mutable_full(), asterisk_daemon(), monitor_sig_flags(), and really_quit().
|
static |
Definition at line 346 of file asterisk.c.
Referenced by __ast_context_destroy(), __ast_internal_context_destroy(), _hup_handler(), add_pri(), add_priority(), ast_add_extension2(), ast_add_extension2_lockopt(), ast_el_add_history(), ast_el_initialize(), ast_el_read_history(), ast_el_write_history(), ast_remotecontrol(), asterisk_daemon(), g722_encode(), handle_cli_dialplan_save(), really_quit(), and show_dialplan_helper().
|
static |
Definition at line 345 of file asterisk.c.
Referenced by ast_el_add_history(), ast_el_initialize(), ast_el_read_history(), ast_el_write_history(), ast_remotecontrol(), asterisk_daemon(), and really_quit().
|
static |
Definition at line 1746 of file asterisk.c.
Referenced by asterisk_daemon().
|
static |
Definition at line 1096 of file asterisk.c.
Referenced by asterisk_daemon().
|
static |
Definition at line 2578 of file asterisk.c.
Referenced by show_license().
|
static |
Definition at line 1373 of file asterisk.c.
Referenced by ast_makesocket(), and really_quit().
|
static |
Definition at line 391 of file asterisk.c.
Referenced by asterisk_daemon().
|
static |
Definition at line 394 of file asterisk.c.
Referenced by ast_register_thread(), asterisk_daemon(), and main().
unsigned int need_el_end |
Definition at line 407 of file asterisk.c.
unsigned int need_quit |
Definition at line 405 of file asterisk.c.
unsigned int need_quit_handler |
Definition at line 406 of file asterisk.c.
unsigned int need_reload |
Definition at line 404 of file asterisk.c.
|
static |
Definition at line 1091 of file asterisk.c.
Referenced by ast_replace_sigchld().
|
static |
Definition at line 799 of file asterisk.c.
Referenced by ast_add_profile(), ast_mark(), ast_profile(), handle_clear_profile(), and handle_show_profile().
Definition at line 2786 of file asterisk.c.
Referenced by ast_app_getdata(), ast_app_getdata_full(), ast_app_getdata_terminator(), auth_exec(), cli_prompt(), handle_speechrecognize(), load_module(), minivm_accmess_exec(), play_files_helper(), and pw_cb().
|
static |
Definition at line 396 of file asterisk.c.
Referenced by asterisk_daemon().
|
static |
Definition at line 347 of file asterisk.c.
Referenced by ast_remotecontrol(), and cli_prompt().
|
static |
Definition at line 389 of file asterisk.c.
Referenced by _hup_handler(), and really_quit().
|
static |
Keep track of how many threads are currently trying to wait*() on a child process.
Definition at line 1104 of file asterisk.c.
Referenced by ast_replace_sigchld(), and ast_unreplace_sigchld().
|
static |
Definition at line 1100 of file asterisk.c.
Referenced by ast_begin_shutdown(), ast_cancel_shutdown(), ast_replace_sigchld(), ast_unreplace_sigchld(), and can_safely_quit().
|
static |
Definition at line 1105 of file asterisk.c.
Referenced by ast_replace_sigchld(), and ast_unreplace_sigchld().
|
static |
Prevent new channel allocation for shutdown.
Definition at line 387 of file asterisk.c.
Referenced by ast_begin_shutdown(), ast_cancel_shutdown(), and ast_shutting_down().
|
static |
Definition at line 384 of file asterisk.c.
Referenced by ast_begin_shutdown(), ast_cancel_shutdown(), ast_shutdown_final(), can_safely_quit(), and wait_for_channels_to_die().
|
static |
Definition at line 402 of file asterisk.c.
Referenced by __quit_handler(), _hup_handler(), asterisk_daemon(), monitor_sig_flags(), and really_quit().
struct { ... } sig_flags |
|
static |
Definition at line 3537 of file asterisk.c.
Referenced by run_startup_commands().
|
static |
|
static |
Definition at line 1723 of file asterisk.c.
Referenced by asterisk_daemon().
|
static |
Definition at line 2535 of file asterisk.c.
Referenced by show_warranty().