
Go to the source code of this file.
Functions | |
| void | ast_autoservice_init (void) |
| void | ast_builtins_init (void) |
| initialize the _full_cmd string in * each of the builtins. | |
| void | ast_channels_init (void) |
| int | ast_device_state_engine_init (void) |
| Initialize the device state engine in separate thread. | |
| void | ast_event_init (void) |
| int | ast_features_init (void) |
| int | ast_file_init (void) |
| int | ast_module_reload (const char *name) |
| Reload asterisk modules. | |
| void | ast_process_pending_reloads (void) |
| Process reload requests received during startup. | |
| int | ast_ssl_init (void) |
| int | ast_term_init (void) |
| int | astdb_init (void) |
| int | astobj2_init (void) |
| void | close_logger (void) |
| int | dnsmgr_init (void) |
| int | dnsmgr_reload (void) |
| void | dnsmgr_start_refresh (void) |
| int | init_framer (void) |
| int | init_logger (void) |
| int | load_modules (unsigned int) |
| int | load_pbx (void) |
| void | threadstorage_init (void) |
Definition in file _private.h.
| void ast_autoservice_init | ( | void | ) |
Provided by autoservice.c
Definition at line 318 of file autoservice.c.
References as_cond, and ast_cond_init().
Referenced by main().
00319 { 00320 ast_cond_init(&as_cond, NULL); 00321 }
| void ast_builtins_init | ( | void | ) |
initialize the _full_cmd string in * each of the builtins.
Provided by cli.c
Definition at line 1251 of file cli.c.
References ast_cli_register_multiple(), and cli_cli.
Referenced by main().
01252 { 01253 ast_cli_register_multiple(cli_cli, sizeof(cli_cli) / sizeof(struct ast_cli_entry)); 01254 }
| void ast_channels_init | ( | void | ) |
Provided by channel.c
Definition at line 5451 of file channel.c.
References ARRAY_LEN, ast_cli_register_multiple(), and cli_channel.
Referenced by main().
05452 { 05453 ast_cli_register_multiple(cli_channel, ARRAY_LEN(cli_channel)); 05454 }
| int ast_device_state_engine_init | ( | void | ) |
Initialize the device state engine in separate thread.
Provided by devicestate.c
Definition at line 528 of file devicestate.c.
References ast_cond_init(), ast_log(), ast_pthread_create_background, change_pending, change_thread, do_devstate_changes(), and LOG_ERROR.
Referenced by main().
00529 { 00530 ast_cond_init(&change_pending, NULL); 00531 if (ast_pthread_create_background(&change_thread, NULL, do_devstate_changes, NULL) < 0) { 00532 ast_log(LOG_ERROR, "Unable to start device state change thread.\n"); 00533 return -1; 00534 } 00535 00536 return 0; 00537 }
| void ast_event_init | ( | void | ) |
Provided by event.c
Definition at line 804 of file event.c.
References ast_cond_init(), ast_event_cache, ast_event_dispatcher(), ast_event_subs, AST_EVENT_TOTAL, ast_pthread_create_background, AST_RWLIST_HEAD_INIT, event_thread, and NUM_EVENT_THREADS.
Referenced by main().
00805 { 00806 int i; 00807 00808 for (i = 0; i < AST_EVENT_TOTAL; i++) 00809 AST_RWLIST_HEAD_INIT(&ast_event_subs[i]); 00810 00811 for (i = 0; i < AST_EVENT_TOTAL; i++) 00812 AST_RWLIST_HEAD_INIT(&ast_event_cache[i]); 00813 00814 ast_cond_init(&event_thread.cond, NULL); 00815 00816 for (i = 0; i < NUM_EVENT_THREADS; i++) { 00817 pthread_t dont_care; 00818 ast_pthread_create_background(&dont_care, NULL, ast_event_dispatcher, NULL); 00819 } 00820 }
| int ast_features_init | ( | void | ) |
Provided by features.c
Definition at line 4046 of file features.c.
References action_bridge(), ast_cli_register_multiple(), ast_devstate_prov_add(), ast_manager_register, ast_manager_register2(), ast_pthread_create, ast_register_application2(), bridge_exec(), descrip, descrip2, do_parking_thread(), EVENT_FLAG_CALL, load_config(), manager_park(), manager_parking_status(), metermaidstate(), park_call_exec(), park_exec(), parkcall, parkedcall, parking_con, parking_ext, synopsis, and synopsis2.
Referenced by main().
04047 { 04048 int res; 04049 04050 ast_register_application2(app_bridge, bridge_exec, bridge_synopsis, bridge_descrip, NULL); 04051 04052 memset(parking_ext, 0, sizeof(parking_ext)); 04053 memset(parking_con, 0, sizeof(parking_con)); 04054 04055 if ((res = load_config())) 04056 return res; 04057 ast_cli_register_multiple(cli_features, sizeof(cli_features) / sizeof(struct ast_cli_entry)); 04058 ast_pthread_create(&parking_thread, NULL, do_parking_thread, NULL); 04059 res = ast_register_application2(parkedcall, park_exec, synopsis, descrip, NULL); 04060 if (!res) 04061 res = ast_register_application2(parkcall, park_call_exec, synopsis2, descrip2, NULL); 04062 if (!res) { 04063 ast_manager_register("ParkedCalls", 0, manager_parking_status, "List parked calls"); 04064 ast_manager_register2("Park", EVENT_FLAG_CALL, manager_park, 04065 "Park a channel", mandescr_park); 04066 ast_manager_register2("Bridge", EVENT_FLAG_CALL, action_bridge, "Bridge two channels already in the PBX", mandescr_bridge); 04067 } 04068 04069 res |= ast_devstate_prov_add("Park", metermaidstate); 04070 04071 return res; 04072 }
| int ast_file_init | ( | void | ) |
Provided by file.c
Definition at line 1378 of file file.c.
References ast_cli_register_multiple().
Referenced by main().
01379 { 01380 ast_cli_register_multiple(cli_file, sizeof(cli_file) / sizeof(struct ast_cli_entry)); 01381 return 0; 01382 }
| int ast_module_reload | ( | const char * | name | ) |
Reload asterisk modules.
| name | the name of the module to reload |
| 1 | if the module was found but cannot be reloaded. | |
| -1 | if a reload operation is already in progress. | |
| 2 | if the specfied module was found and reloaded. |
Definition at line 618 of file loader.c.
References ast_fully_booted, ast_lastreloadtime, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log(), ast_mutex_trylock(), ast_mutex_unlock(), ast_tvnow(), ast_verb, ast_verbose(), ast_module::declined, ast_module_info::description, ast_module::flags, ast_module::info, LOG_NOTICE, queue_reload_request(), ast_module_info::reload, ast_module::resource, resource_name_match(), and ast_module::running.
Referenced by action_reload(), action_updateconfig(), ast_process_pending_reloads(), handle_reload(), manager_moduleload(), and monitor_sig_flags().
00619 { 00620 struct ast_module *cur; 00621 int res = 0; /* return value. 0 = not found, others, see below */ 00622 int i; 00623 00624 /* If we aren't fully booted, we just pretend we reloaded but we queue this 00625 up to run once we are booted up. */ 00626 if (!ast_fully_booted) { 00627 queue_reload_request(name); 00628 return 0; 00629 } 00630 00631 if (ast_mutex_trylock(&reloadlock)) { 00632 ast_verbose("The previous reload command didn't finish yet\n"); 00633 return -1; /* reload already in progress */ 00634 } 00635 ast_lastreloadtime = ast_tvnow(); 00636 00637 /* Call "predefined" reload here first */ 00638 for (i = 0; reload_classes[i].name; i++) { 00639 if (!name || !strcasecmp(name, reload_classes[i].name)) { 00640 reload_classes[i].reload_fn(); /* XXX should check error ? */ 00641 res = 2; /* found and reloaded */ 00642 } 00643 } 00644 00645 if (name && res) { 00646 ast_mutex_unlock(&reloadlock); 00647 return res; 00648 } 00649 00650 AST_LIST_LOCK(&module_list); 00651 AST_LIST_TRAVERSE(&module_list, cur, entry) { 00652 const struct ast_module_info *info = cur->info; 00653 00654 if (name && resource_name_match(name, cur->resource)) 00655 continue; 00656 00657 if (!cur->flags.running || cur->flags.declined) { 00658 if (!name) 00659 continue; 00660 ast_log(LOG_NOTICE, "The module '%s' was not properly initialized. " 00661 "Before reloading the module, you must run \"module load %s\" " 00662 "and fix whatever is preventing the module from being initialized.\n", 00663 name, name); 00664 res = 2; /* Don't report that the module was not found */ 00665 break; 00666 } 00667 00668 if (!info->reload) { /* cannot be reloaded */ 00669 if (res < 1) /* store result if possible */ 00670 res = 1; /* 1 = no reload() method */ 00671 continue; 00672 } 00673 00674 res = 2; 00675 ast_verb(3, "Reloading module '%s' (%s)\n", cur->resource, info->description); 00676 info->reload(); 00677 } 00678 AST_LIST_UNLOCK(&module_list); 00679 00680 ast_mutex_unlock(&reloadlock); 00681 00682 return res; 00683 }
| void ast_process_pending_reloads | ( | void | ) |
Process reload requests received during startup.
This function requests that the loader execute the pending reload requests that were queued during server startup.
Definition at line 553 of file loader.c.
References ast_free, ast_fully_booted, AST_LIST_LOCK, AST_LIST_REMOVE_HEAD, AST_LIST_UNLOCK, ast_log(), ast_module_reload(), do_full_reload, LOG_NOTICE, and reload_queue_item::module.
Referenced by main().
00554 { 00555 struct reload_queue_item *item; 00556 00557 if (!ast_fully_booted) { 00558 return; 00559 } 00560 00561 AST_LIST_LOCK(&reload_queue); 00562 00563 if (do_full_reload) { 00564 do_full_reload = 0; 00565 AST_LIST_UNLOCK(&reload_queue); 00566 ast_log(LOG_NOTICE, "Executing deferred reload request.\n"); 00567 ast_module_reload(NULL); 00568 return; 00569 } 00570 00571 while ((item = AST_LIST_REMOVE_HEAD(&reload_queue, entry))) { 00572 ast_log(LOG_NOTICE, "Executing deferred reload request for module '%s'.\n", item->module); 00573 ast_module_reload(item->module); 00574 ast_free(item); 00575 } 00576 00577 AST_LIST_UNLOCK(&reload_queue); 00578 }
| int ast_ssl_init | ( | void | ) |
Porvided by ssl.c
Definition at line 73 of file ssl.c.
References ast_calloc, and ast_mutex_init().
Referenced by main().
00074 { 00075 #ifdef HAVE_OPENSSL 00076 unsigned int i; 00077 00078 SSL_library_init(); 00079 SSL_load_error_strings(); 00080 ERR_load_crypto_strings(); 00081 ERR_load_BIO_strings(); 00082 OpenSSL_add_all_algorithms(); 00083 00084 /* Make OpenSSL thread-safe. */ 00085 00086 CRYPTO_set_id_callback(ssl_threadid); 00087 00088 ssl_num_locks = CRYPTO_num_locks(); 00089 if (!(ssl_locks = ast_calloc(ssl_num_locks, sizeof(ssl_locks[0])))) { 00090 return -1; 00091 } 00092 for (i = 0; i < ssl_num_locks; i++) { 00093 ast_mutex_init(&ssl_locks[i]); 00094 } 00095 CRYPTO_set_locking_callback(ssl_lock); 00096 00097 #endif /* HAVE_OPENSSL */ 00098 return 0; 00099 }
| int ast_term_init | ( | void | ) |
Provided by term.c
Definition at line 69 of file term.c.
References ast_opt_console, ast_opt_no_color, ast_opt_no_fork, ATTR_BRIGHT, ATTR_RESET, COLOR_BLACK, COLOR_BROWN, COLOR_WHITE, convshort(), and ESC.
Referenced by main().
00070 { 00071 char *term = getenv("TERM"); 00072 char termfile[256] = ""; 00073 char buffer[512] = ""; 00074 int termfd = -1, parseokay = 0, i; 00075 00076 if (!term) 00077 return 0; 00078 if (!ast_opt_console || ast_opt_no_color || !ast_opt_no_fork) 00079 return 0; 00080 00081 for (i=0 ;; i++) { 00082 if (termpath[i] == NULL) { 00083 break; 00084 } 00085 snprintf(termfile, sizeof(termfile), "%s/%c/%s", termpath[i], *term, term); 00086 termfd = open(termfile, O_RDONLY); 00087 if (termfd > -1) { 00088 break; 00089 } 00090 } 00091 if (termfd > -1) { 00092 int actsize = read(termfd, buffer, sizeof(buffer) - 1); 00093 short sz_names = convshort(buffer + 2); 00094 short sz_bools = convshort(buffer + 4); 00095 short n_nums = convshort(buffer + 6); 00096 00097 /* if ((sz_names + sz_bools) & 1) 00098 sz_bools++; */ 00099 00100 if (sz_names + sz_bools + n_nums < actsize) { 00101 /* Offset 13 is defined in /usr/include/term.h, though we do not 00102 * include it here, as it conflicts with include/asterisk/term.h */ 00103 short max_colors = convshort(buffer + 12 + sz_names + sz_bools + 13 * 2); 00104 if (max_colors > 0) { 00105 vt100compat = 1; 00106 } 00107 parseokay = 1; 00108 } 00109 close(termfd); 00110 } 00111 00112 if (!parseokay) { 00113 /* These comparisons should not be substrings nor case-insensitive, as 00114 * terminal types are very particular about how they treat suffixes and 00115 * capitalization. For example, terminal type 'linux-m' does NOT 00116 * support color, while 'linux' does. Not even all vt100* terminals 00117 * support color, either (e.g. 'vt100+fnkeys'). */ 00118 if (!strcmp(term, "linux")) { 00119 vt100compat = 1; 00120 } else if (!strcmp(term, "xterm")) { 00121 vt100compat = 1; 00122 } else if (!strcmp(term, "xterm-color")) { 00123 vt100compat = 1; 00124 } else if (!strncmp(term, "Eterm", 5)) { 00125 /* Both entries which start with Eterm support color */ 00126 vt100compat = 1; 00127 } else if (!strcmp(term, "vt100")) { 00128 vt100compat = 1; 00129 } else if (!strncmp(term, "crt", 3)) { 00130 /* Both crt terminals support color */ 00131 vt100compat = 1; 00132 } 00133 } 00134 00135 if (vt100compat) { 00136 /* Make commands show up in nice colors */ 00137 snprintf(prepdata, sizeof(prepdata), "%c[%d;%d;%dm", ESC, ATTR_BRIGHT, COLOR_BROWN, COLOR_BLACK + 10); 00138 snprintf(enddata, sizeof(enddata), "%c[%d;%d;%dm", ESC, ATTR_RESET, COLOR_WHITE, COLOR_BLACK + 10); 00139 snprintf(quitdata, sizeof(quitdata), "%c[0m", ESC); 00140 } 00141 return 0; 00142 }
| int astdb_init | ( | void | ) |
Provided by db.c
Definition at line 665 of file db.c.
References ast_cli_register_multiple(), ast_manager_register, dbinit(), EVENT_FLAG_REPORTING, EVENT_FLAG_SYSTEM, manager_dbdel(), manager_dbdeltree(), manager_dbget(), and manager_dbput().
Referenced by main().
00666 { 00667 dbinit(); 00668 ast_cli_register_multiple(cli_database, sizeof(cli_database) / sizeof(struct ast_cli_entry)); 00669 ast_manager_register("DBGet", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_dbget, "Get DB Entry"); 00670 ast_manager_register("DBPut", EVENT_FLAG_SYSTEM, manager_dbput, "Put DB Entry"); 00671 ast_manager_register("DBDel", EVENT_FLAG_SYSTEM, manager_dbdel, "Delete DB Entry"); 00672 ast_manager_register("DBDelTree", EVENT_FLAG_SYSTEM, manager_dbdeltree, "Delete DB Tree"); 00673 return 0; 00674 }
| int astobj2_init | ( | void | ) |
Provided by astobj2.c
Definition at line 798 of file astobj2.c.
References ARRAY_LEN, and ast_cli_register_multiple().
Referenced by main().
00799 { 00800 #ifdef AO2_DEBUG 00801 ast_cli_register_multiple(cli_astobj2, ARRAY_LEN(cli_astobj2)); 00802 #endif 00803 00804 return 0; 00805 }
| void close_logger | ( | void | ) |
Provided by logger.c
Definition at line 954 of file logger.c.
References ast_cond_signal(), AST_LIST_LOCK, AST_LIST_UNLOCK, AST_PTHREADT_NULL, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, close_logger_thread, eventlog, f, logchannel::fileptr, logchannel::list, logcond, logthread, and qlog.
Referenced by quit_handler().
00956 { 00957 struct logchannel *f = NULL; 00958 00959 /* Stop logger thread */ 00960 AST_LIST_LOCK(&logmsgs); 00961 close_logger_thread = 1; 00962 ast_cond_signal(&logcond); 00963 AST_LIST_UNLOCK(&logmsgs); 00964 00965 if (logthread != AST_PTHREADT_NULL) 00966 pthread_join(logthread, NULL); 00967 00968 AST_RWLIST_WRLOCK(&logchannels); 00969 00970 if (eventlog) { 00971 fclose(eventlog); 00972 eventlog = NULL; 00973 } 00974 00975 if (qlog) { 00976 fclose(qlog); 00977 qlog = NULL; 00978 } 00979 00980 AST_RWLIST_TRAVERSE(&logchannels, f, list) { 00981 if (f->fileptr && (f->fileptr != stdout) && (f->fileptr != stderr)) { 00982 fclose(f->fileptr); 00983 f->fileptr = NULL; 00984 } 00985 } 00986 00987 closelog(); /* syslog */ 00988 00989 AST_RWLIST_UNLOCK(&logchannels); 00990 00991 return;
| int dnsmgr_init | ( | void | ) |
Provided by dnsmgr.c
Definition at line 350 of file dnsmgr.c.
References ast_cli_register(), ast_log(), cli_refresh, cli_reload, cli_status, do_reload(), LOG_ERROR, and sched_context_create().
Referenced by main().
00351 { 00352 if (!(sched = sched_context_create())) { 00353 ast_log(LOG_ERROR, "Unable to create schedule context.\n"); 00354 return -1; 00355 } 00356 ast_cli_register(&cli_reload); 00357 ast_cli_register(&cli_status); 00358 ast_cli_register(&cli_refresh); 00359 return do_reload(1); 00360 }
| int dnsmgr_reload | ( | void | ) |
Provided by dnsmgr.c
Definition at line 362 of file dnsmgr.c.
References do_reload().
00363 { 00364 return do_reload(0); 00365 }
| void dnsmgr_start_refresh | ( | void | ) |
Provided by dnsmgr.c
Definition at line 244 of file dnsmgr.c.
References ast_sched_add_variable(), AST_SCHED_DEL, master_refresh_info, and refresh_list().
Referenced by main().
00245 { 00246 if (refresh_sched > -1) { 00247 AST_SCHED_DEL(sched, refresh_sched); 00248 refresh_sched = ast_sched_add_variable(sched, 100, refresh_list, &master_refresh_info, 1); 00249 } 00250 }
| int init_framer | ( | void | ) |
Provided by frame.c
Definition at line 949 of file frame.c.
References ast_cli_register_multiple().
Referenced by main().
00950 { 00951 ast_cli_register_multiple(my_clis, sizeof(my_clis) / sizeof(struct ast_cli_entry)); 00952 return 0; 00953 }
| int init_logger | ( | void | ) |
Provided by logger.c
Definition at line 910 of file logger.c.
References ast_cli_register_multiple(), ast_cond_destroy(), ast_cond_init(), ast_config_AST_LOG_DIR, ast_log(), ast_mkdir(), ast_pthread_create, ast_queue_log(), ast_verb, cli_logger, errno, eventlog, EVENTLOG, handle_SIGXFSZ(), init_logger_chain(), LOG_ERROR, LOG_EVENT, logcond, logfiles, logger_thread(), logthread, and qlog.
Referenced by main().
00912 { 00913 char tmp[256]; 00914 int res = 0; 00915 00916 /* auto rotate if sig SIGXFSZ comes a-knockin */ 00917 (void) signal(SIGXFSZ, (void *) handle_SIGXFSZ); 00918 00919 /* start logger thread */ 00920 ast_cond_init(&logcond, NULL); 00921 if (ast_pthread_create(&logthread, NULL, logger_thread, NULL) < 0) { 00922 ast_cond_destroy(&logcond); 00923 return -1; 00924 } 00925 00926 /* register the logger cli commands */ 00927 ast_cli_register_multiple(cli_logger, sizeof(cli_logger) / sizeof(struct ast_cli_entry)); 00928 00929 ast_mkdir(ast_config_AST_LOG_DIR, 0777); 00930 00931 /* create log channels */ 00932 init_logger_chain(0 /* locked */); 00933 00934 /* create the eventlog */ 00935 if (logfiles.event_log) { 00936 snprintf(tmp, sizeof(tmp), "%s/%s", ast_config_AST_LOG_DIR, EVENTLOG); 00937 eventlog = fopen(tmp, "a"); 00938 if (eventlog) { 00939 ast_log(LOG_EVENT, "Started Asterisk Event Logger\n"); 00940 ast_verb(1, "Asterisk Event Logger Started %s\n", tmp); 00941 } else { 00942 ast_log(LOG_ERROR, "Unable to create event log: %s\n", strerror(errno)); 00943 res = -1; 00944 } 00945 } 00946 00947 if (logfiles.queue_log) { 00948 snprintf(tmp, sizeof(tmp), "%s/%s", ast_config_AST_LOG_DIR, queue_log_name); 00949 qlog = fopen(tmp, "a"); 00950 ast_queue_log("NONE", "NONE", "NONE", "QUEUESTART", "%s", ""); 00951 } 00952 return res;
| int load_modules | ( | unsigned | int | ) |
Provided by loader.c
Definition at line 822 of file loader.c.
References add_to_load_order(), ast_config_AST_MODULE_DIR, ast_config_destroy(), ast_config_load, ast_free, AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_LOCK, AST_LIST_REMOVE_CURRENT, AST_LIST_REMOVE_HEAD, AST_LIST_TRAVERSE, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, ast_log(), AST_MODULE_CONFIG, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_SKIP, AST_MODULE_LOAD_SUCCESS, ast_opt_quiet, ast_true(), ast_variable_browse(), ast_variable_retrieve(), ast_verb, dir, embedding, EVENT_FLAG_SYSTEM, find_resource(), ast_module::flags, ast_module::lib, load_resource(), LOG_NOTICE, LOG_WARNING, manager_event, ast_variable::name, ast_variable::next, load_order_entry::resource, ast_module::resource, resource_name_match(), ast_module::running, and ast_variable::value.
Referenced by main().
00823 { 00824 struct ast_config *cfg; 00825 struct ast_module *mod; 00826 struct load_order_entry *order; 00827 struct ast_variable *v; 00828 unsigned int load_count; 00829 struct load_order load_order; 00830 int res = 0; 00831 struct ast_flags config_flags = { 0 }; 00832 int modulecount = 0; 00833 00834 #ifdef LOADABLE_MODULES 00835 struct dirent *dirent; 00836 DIR *dir; 00837 #endif 00838 00839 /* all embedded modules have registered themselves by now */ 00840 embedding = 0; 00841 00842 ast_verb(1, "Asterisk Dynamic Loader Starting:\n"); 00843 00844 AST_LIST_HEAD_INIT_NOLOCK(&load_order); 00845 00846 AST_LIST_LOCK(&module_list); 00847 00848 if (embedded_module_list.first) { 00849 module_list.first = embedded_module_list.first; 00850 module_list.last = embedded_module_list.last; 00851 embedded_module_list.first = NULL; 00852 } 00853 00854 if (!(cfg = ast_config_load(AST_MODULE_CONFIG, config_flags))) { 00855 ast_log(LOG_WARNING, "No '%s' found, no modules will be loaded.\n", AST_MODULE_CONFIG); 00856 goto done; 00857 } 00858 00859 /* first, find all the modules we have been explicitly requested to load */ 00860 for (v = ast_variable_browse(cfg, "modules"); v; v = v->next) { 00861 if (!strcasecmp(v->name, preload_only ? "preload" : "load")) { 00862 add_to_load_order(v->value, &load_order); 00863 } 00864 } 00865 00866 /* check if 'autoload' is on */ 00867 if (!preload_only && ast_true(ast_variable_retrieve(cfg, "modules", "autoload"))) { 00868 /* if so, first add all the embedded modules that are not already running to the load order */ 00869 AST_LIST_TRAVERSE(&module_list, mod, entry) { 00870 /* if it's not embedded, skip it */ 00871 if (mod->lib) 00872 continue; 00873 00874 if (mod->flags.running) 00875 continue; 00876 00877 order = add_to_load_order(mod->resource, &load_order); 00878 } 00879 00880 #ifdef LOADABLE_MODULES 00881 /* if we are allowed to load dynamic modules, scan the directory for 00882 for all available modules and add them as well */ 00883 if ((dir = opendir(ast_config_AST_MODULE_DIR))) { 00884 while ((dirent = readdir(dir))) { 00885 int ld = strlen(dirent->d_name); 00886 00887 /* Must end in .so to load it. */ 00888 00889 if (ld < 4) 00890 continue; 00891 00892 if (strcasecmp(dirent->d_name + ld - 3, ".so")) 00893 continue; 00894 00895 /* if there is already a module by this name in the module_list, 00896 skip this file */ 00897 if (find_resource(dirent->d_name, 0)) 00898 continue; 00899 00900 add_to_load_order(dirent->d_name, &load_order); 00901 } 00902 00903 closedir(dir); 00904 } else { 00905 if (!ast_opt_quiet) 00906 ast_log(LOG_WARNING, "Unable to open modules directory '%s'.\n", 00907 ast_config_AST_MODULE_DIR); 00908 } 00909 #endif 00910 } 00911 00912 /* now scan the config for any modules we are prohibited from loading and 00913 remove them from the load order */ 00914 for (v = ast_variable_browse(cfg, "modules"); v; v = v->next) { 00915 if (strcasecmp(v->name, "noload")) 00916 continue; 00917 00918 AST_LIST_TRAVERSE_SAFE_BEGIN(&load_order, order, entry) { 00919 if (!resource_name_match(order->resource, v->value)) { 00920 AST_LIST_REMOVE_CURRENT(entry); 00921 ast_free(order->resource); 00922 ast_free(order); 00923 } 00924 } 00925 AST_LIST_TRAVERSE_SAFE_END; 00926 } 00927 00928 /* we are done with the config now, all the information we need is in the 00929 load_order list */ 00930 ast_config_destroy(cfg); 00931 00932 load_count = 0; 00933 AST_LIST_TRAVERSE(&load_order, order, entry) 00934 load_count++; 00935 00936 if (load_count) 00937 ast_log(LOG_NOTICE, "%d modules will be loaded.\n", load_count); 00938 00939 /* first, load only modules that provide global symbols */ 00940 AST_LIST_TRAVERSE_SAFE_BEGIN(&load_order, order, entry) { 00941 switch (load_resource(order->resource, 1)) { 00942 case AST_MODULE_LOAD_SUCCESS: 00943 modulecount++; 00944 case AST_MODULE_LOAD_DECLINE: 00945 AST_LIST_REMOVE_CURRENT(entry); 00946 ast_free(order->resource); 00947 ast_free(order); 00948 break; 00949 case AST_MODULE_LOAD_FAILURE: 00950 res = -1; 00951 goto done; 00952 case AST_MODULE_LOAD_SKIP: 00953 /* try again later */ 00954 break; 00955 } 00956 } 00957 AST_LIST_TRAVERSE_SAFE_END; 00958 00959 /* now load everything else */ 00960 AST_LIST_TRAVERSE_SAFE_BEGIN(&load_order, order, entry) { 00961 switch (load_resource(order->resource, 0)) { 00962 case AST_MODULE_LOAD_SUCCESS: 00963 modulecount++; 00964 case AST_MODULE_LOAD_DECLINE: 00965 AST_LIST_REMOVE_CURRENT(entry); 00966 ast_free(order->resource); 00967 ast_free(order); 00968 break; 00969 case AST_MODULE_LOAD_FAILURE: 00970 res = -1; 00971 goto done; 00972 case AST_MODULE_LOAD_SKIP: 00973 /* should not happen */ 00974 break; 00975 } 00976 } 00977 AST_LIST_TRAVERSE_SAFE_END; 00978 00979 done: 00980 while ((order = AST_LIST_REMOVE_HEAD(&load_order, entry))) { 00981 ast_free(order->resource); 00982 ast_free(order); 00983 } 00984 00985 AST_LIST_UNLOCK(&module_list); 00986 00987 /* Tell manager clients that are aggressive at logging in that we're done 00988 loading modules. If there's a DNS problem in chan_sip, we might not 00989 even reach this */ 00990 manager_event(EVENT_FLAG_SYSTEM, "ModuleLoadReport", "ModuleLoadStatus: Done\r\nModuleSelection: %s\r\nModuleCount: %d\r\n", preload_only ? "Preload" : "All", modulecount); 00991 00992 return res; 00993 }
| int load_pbx | ( | void | ) |
Provided by pbx.c
Definition at line 8359 of file pbx.c.
References __ast_custom_function_register(), ast_cli_register_multiple(), ast_cond_init(), AST_EVENT_DEVICE_STATE, AST_EVENT_IE_END, ast_event_subscribe(), ast_log(), ast_manager_register2(), ast_mutex_init(), ast_pthread_create, ast_register_application2(), ast_verb, builtins, device_state, device_state_cb(), device_state_thread(), EVENT_FLAG_CONFIG, EVENT_FLAG_REPORTING, exception_function, LOG_ERROR, manager_show_dialplan(), mandescr_show_dialplan, and pbx_cli.
Referenced by main().
08360 { 08361 int x; 08362 08363 /* Initialize the PBX */ 08364 ast_verb(1, "Asterisk PBX Core Initializing\n"); 08365 ast_verb(1, "Registering builtin applications:\n"); 08366 08367 ast_cli_register_multiple(pbx_cli, sizeof(pbx_cli) / sizeof(struct ast_cli_entry)); 08368 __ast_custom_function_register(&exception_function, NULL); 08369 08370 /* Register builtin applications */ 08371 for (x = 0; x < sizeof(builtins) / sizeof(struct pbx_builtin); x++) { 08372 ast_verb(1, "[%s]\n", builtins[x].name); 08373 if (ast_register_application2(builtins[x].name, builtins[x].execute, builtins[x].synopsis, builtins[x].description, NULL)) { 08374 ast_log(LOG_ERROR, "Unable to register builtin application '%s'\n", builtins[x].name); 08375 return -1; 08376 } 08377 } 08378 08379 /* Register manager application */ 08380 ast_manager_register2("ShowDialPlan", EVENT_FLAG_CONFIG | EVENT_FLAG_REPORTING, manager_show_dialplan, "List dialplan", mandescr_show_dialplan); 08381 08382 ast_mutex_init(&device_state.lock); 08383 ast_cond_init(&device_state.cond, NULL); 08384 ast_pthread_create(&device_state.thread, NULL, device_state_thread, NULL); 08385 08386 if (!(device_state_sub = ast_event_subscribe(AST_EVENT_DEVICE_STATE, device_state_cb, NULL, 08387 AST_EVENT_IE_END))) { 08388 return -1; 08389 } 08390 08391 return 0; 08392 }
| void threadstorage_init | ( | void | ) |
1.5.6