Startup/Shutdown
[Core Library]

Collaboration diagram for Startup/Shutdown:

Functions

switch_status_t switch_core_init (_In_ switch_core_flag_t flags, _In_ switch_bool_t console, _Out_ const char **err)
 Initilize the core.
switch_status_t switch_core_init_and_modload (_In_ switch_core_flag_t flags, _In_ switch_bool_t console, _Out_ const char **err)
 Initilize the core and load modules.
uint32_t switch_core_session_limit (_In_ uint32_t new_limit)
 Set/Get Session Limit.
uint32_t switch_core_sessions_per_second (_In_ uint32_t new_limit)
 Set/Get Session Rate Limit.
switch_status_t switch_core_destroy (void)
 Destroy the core.


Function Documentation

switch_status_t switch_core_destroy ( void   ) 

Destroy the core.

Note:
to be called at application shutdown

Definition at line 2313 of file switch_core.c.

References switch_directories::base_dir, switch_directories::conf_dir, switch_runtime::console, switch_directories::db_dir, switch_runtime::global_vars, switch_directories::grammar_dir, switch_ip_list_t::hash, switch_directories::htdocs_dir, IP_LIST, switch_directories::log_dir, switch_runtime::memory_pool, switch_runtime::mime_types, switch_directories::mod_dir, switch_ip_list_t::pool, switch_runtime::ptimes, switch_directories::recordings_dir, switch_directories::run_dir, runtime, SCF_NO_NEW_SESSIONS, SCF_RESTART, SCF_SHUTTING_DOWN, SCF_USE_AUTO_NAT, SCF_USE_SQL, switch_directories::script_dir, switch_directories::sounds_dir, switch_directories::storage_dir, SWITCH_CAUSE_SYSTEM_SHUTDOWN, SWITCH_CHANNEL_LOG, switch_console_shutdown(), switch_core_destroy_memory_pool, switch_core_hash_destroy(), switch_core_memory_stop(), switch_core_session_hupall(), switch_core_sqldb_stop(), switch_core_unset_variables(), switch_event_add_header(), switch_event_create, switch_event_destroy(), switch_event_fire, SWITCH_EVENT_SHUTDOWN, switch_event_shutdown(), SWITCH_GLOBAL_dirs, switch_loadable_module_shutdown(), SWITCH_LOG_CONSOLE, switch_log_printf(), switch_log_shutdown(), switch_nat_shutdown(), switch_rtp_shutdown(), switch_safe_free, switch_scheduler_task_thread_stop(), switch_set_flag, switch_ssl_destroy_ssl_locks(), SWITCH_STACK_BOTTOM, SWITCH_STATUS_RESTART, SWITCH_STATUS_SUCCESS, switch_test_flag, switch_xml_destroy(), and switch_directories::temp_dir.

Referenced by fs_core_destroy(), and main().

02314 {
02315         switch_event_t *event;
02316 
02317         if (switch_event_create(&event, SWITCH_EVENT_SHUTDOWN) == SWITCH_STATUS_SUCCESS) {
02318                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Event-Info", "System Shutting Down");
02319                 switch_event_fire(&event);
02320         }
02321 
02322         switch_set_flag((&runtime), SCF_NO_NEW_SESSIONS);
02323         switch_set_flag((&runtime), SCF_SHUTTING_DOWN);
02324 
02325         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "End existing sessions\n");
02326         switch_core_session_hupall(SWITCH_CAUSE_SYSTEM_SHUTDOWN);
02327         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Clean up modules.\n");
02328 
02329         switch_loadable_module_shutdown();
02330 
02331         switch_ssl_destroy_ssl_locks();
02332 
02333         if (switch_test_flag((&runtime), SCF_USE_SQL)) {
02334                 switch_core_sqldb_stop();
02335         }
02336         switch_scheduler_task_thread_stop();
02337 
02338         switch_rtp_shutdown();
02339 
02340         if (switch_test_flag((&runtime), SCF_USE_AUTO_NAT)) {
02341                 switch_nat_shutdown();
02342         }
02343         switch_xml_destroy();
02344 
02345         switch_console_shutdown();
02346 
02347         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Closing Event Engine.\n");
02348         switch_event_shutdown();
02349 
02350         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Finalizing Shutdown.\n");
02351         switch_log_shutdown();
02352 
02353         switch_core_unset_variables();
02354         switch_core_memory_stop();
02355 
02356         if (runtime.console && runtime.console != stdout && runtime.console != stderr) {
02357                 fclose(runtime.console);
02358                 runtime.console = NULL;
02359         }
02360 
02361         switch_safe_free(SWITCH_GLOBAL_dirs.base_dir);
02362         switch_safe_free(SWITCH_GLOBAL_dirs.mod_dir);
02363         switch_safe_free(SWITCH_GLOBAL_dirs.conf_dir);
02364         switch_safe_free(SWITCH_GLOBAL_dirs.log_dir);
02365         switch_safe_free(SWITCH_GLOBAL_dirs.db_dir);
02366         switch_safe_free(SWITCH_GLOBAL_dirs.script_dir);
02367         switch_safe_free(SWITCH_GLOBAL_dirs.htdocs_dir);
02368         switch_safe_free(SWITCH_GLOBAL_dirs.grammar_dir);
02369         switch_safe_free(SWITCH_GLOBAL_dirs.storage_dir);
02370         switch_safe_free(SWITCH_GLOBAL_dirs.recordings_dir);
02371         switch_safe_free(SWITCH_GLOBAL_dirs.sounds_dir);
02372         switch_safe_free(SWITCH_GLOBAL_dirs.run_dir);
02373         switch_safe_free(SWITCH_GLOBAL_dirs.temp_dir);
02374 
02375         switch_event_destroy(&runtime.global_vars);
02376         switch_core_hash_destroy(&runtime.ptimes);
02377         switch_core_hash_destroy(&runtime.mime_types);
02378 
02379         if (IP_LIST.hash) {
02380                 switch_core_hash_destroy(&IP_LIST.hash);
02381         }
02382 
02383         if (IP_LIST.pool) {
02384                 switch_core_destroy_memory_pool(&IP_LIST.pool);
02385         }
02386 
02387         if (runtime.memory_pool) {
02388                 apr_pool_destroy(runtime.memory_pool);
02389                 apr_terminate();
02390         }
02391 
02392         return switch_test_flag((&runtime), SCF_RESTART) ? SWITCH_STATUS_RESTART : SWITCH_STATUS_SUCCESS;
02393 }

switch_status_t switch_core_init ( _In_ switch_core_flag_t  flags,
_In_ switch_bool_t  console,
_Out_ const char **  err 
)

Initilize the core.

Parameters:
console optional FILE stream for output
flags core flags
err a pointer to set any errors to
Note:
to be called at application startup

Referenced by fs_core_init(), main(), and switch_core_init_and_modload().

switch_status_t switch_core_init_and_modload ( _In_ switch_core_flag_t  flags,
_In_ switch_bool_t  console,
_Out_ const char **  err 
)

Initilize the core and load modules.

Parameters:
console optional FILE stream for output
flags core flags
err a pointer to set any errors to
Note:
to be called at application startup instead of switch_core_init. Includes module loading.

Referenced by main().

uint32_t switch_core_session_limit ( _In_ uint32_t  new_limit  ) 

Set/Get Session Limit.

Parameters:
new_limit new value (if > 0)
Returns:
the current session limit

Referenced by send_heartbeat(), switch_core_init_and_modload(), switch_core_session_ctl(), and switch_load_core_config().

uint32_t switch_core_sessions_per_second ( _In_ uint32_t  new_limit  ) 

Set/Get Session Rate Limit.

Parameters:
new_limit new value (if > 0)
Returns:
the current session rate limit

Referenced by switch_core_init_and_modload(), and switch_load_core_config().


Generated on Wed May 16 04:00:18 2012 for FreeSWITCH API Documentation by  doxygen 1.4.7