#include "asterisk/utils.h"
Go to the source code of this file.
Data Structures | |
struct | ast_module_info |
Defines | |
#define | AST_MODULE_CONFIG "modules.conf" |
Module configuration file. | |
#define | AST_MODULE_INFO(keystr, flags_to_set, desc, fields...) |
#define | AST_MODULE_INFO_STANDARD(keystr, desc) |
#define | ast_module_user_add(chan) __ast_module_user_add(ast_module_info->self, chan) |
#define | ast_module_user_hangup_all() __ast_module_user_hangup_all(ast_module_info->self) |
#define | ast_module_user_remove(user) __ast_module_user_remove(ast_module_info->self, user) |
#define | ASTERISK_GPL_KEY "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" |
The text the key() function should return. | |
Enumerations | |
enum | ast_module_flags { AST_MODFLAG_DEFAULT = 0, AST_MODFLAG_GLOBAL_SYMBOLS = (1 << 0), AST_MODFLAG_BUILDSUM = (1 << 1) } |
enum | ast_module_load_result { AST_MODULE_LOAD_SUCCESS = 0, AST_MODULE_LOAD_DECLINE = 1, AST_MODULE_LOAD_SKIP = 2, AST_MODULE_LOAD_FAILURE = -1 } |
enum | ast_module_unload_mode { AST_FORCE_SOFT = 0, AST_FORCE_FIRM = 1, AST_FORCE_HARD = 2 } |
Functions | |
ast_module_user * | __ast_module_user_add (struct ast_module *, struct ast_channel *) |
void | __ast_module_user_hangup_all (struct ast_module *) |
void | __ast_module_user_remove (struct ast_module *, struct ast_module_user *) |
enum ast_module_load_result | ast_load_resource (const char *resource_name) |
Load a module. | |
int | ast_loader_register (int(*updater)(void)) |
Add a procedure to be run when modules have been updated. | |
int | ast_loader_unregister (int(*updater)(void)) |
Remove a procedure to be run when modules are updated. | |
char * | ast_module_helper (const char *line, const char *word, int pos, int state, int rpos, int needsreload) |
Match modules names for the Asterisk cli. | |
ast_module * | ast_module_ref (struct ast_module *) |
void | ast_module_register (const struct ast_module_info *) |
void | ast_module_shutdown (void) |
Run the unload() callback for all loaded modules. | |
void | ast_module_unref (struct ast_module *) |
void | ast_module_unregister (const struct ast_module_info *) |
int | ast_unload_resource (const char *resource_name, enum ast_module_unload_mode) |
Unload a module. | |
int | ast_update_module_list (int(*modentry)(const char *module, const char *description, int usecnt, const char *like), const char *like) |
Ask for a list of modules, descriptions, and use counts. | |
void | ast_update_use_count (void) |
Notify when usecount has been changed. | |
Variables | |
static const struct ast_module_info * | ast_module_info |
This file contains the definitons for functions Asterisk modules should provide and some other module related functions.
Definition in file module.h.
#define AST_MODULE_CONFIG "modules.conf" |
#define AST_MODULE_INFO | ( | keystr, | |||
flags_to_set, | |||||
desc, | |||||
fields... | ) |
#define AST_MODULE_INFO_STANDARD | ( | keystr, | |||
desc | ) |
Value:
AST_MODULE_INFO(keystr, AST_MODFLAG_DEFAULT, desc, \ .load = load_module, \ .unload = unload_module, \ )
#define ast_module_user_add | ( | chan | ) | __ast_module_user_add(ast_module_info->self, chan) |
Definition at line 220 of file module.h.
Referenced by __login_exec(), _macro_exec(), _while_exec(), acf_curl_exec(), acf_cut_exec(), acf_rand_exec(), acf_sort_exec(), acf_vmcount_exec(), admin_exec(), adsi_exec(), agi_exec_full(), alarmreceiver_exec(), amd_exec(), app_exec(), appendcdruserfield_exec(), aqm_exec(), asyncgoto_exec(), auth_exec(), background_detect_exec(), builtin_parkcall(), chanavail_exec(), chanspy_exec(), conf_exec(), controlplayback_exec(), count_exec(), cpeid_exec(), del_exec(), deltree_exec(), dictate_exec(), directory_exec(), disa_exec(), dumpchan_exec(), dundifunc_read(), echo_exec(), exec(), exec_exec(), execif_exec(), extenspy_exec(), festival_exec(), flash_exec(), function_enum(), function_realtime_read(), function_realtime_write(), function_txtcidname(), gosub_exec(), gosubif_exec(), hasvoicemail_exec(), ices_exec(), local_new(), log_exec(), lookupblacklist_exec(), lookupcidname_exec(), macroif_exec(), milliwatt_exec(), mixmonitor_exec(), morsecode_exec(), mp3_exec(), nbs_new(), NBScat_exec(), nocdr_exec(), ospauth_exec(), ospfinished_exec(), osplookup_exec(), ospnext_exec(), page_exec(), park_call_exec(), park_exec(), parkandannounce_exec(), pickup_exec(), playback_exec(), pqm_exec(), privacy_exec(), ql_exec(), queue_exec(), queue_function_queuemembercount(), queue_function_queuememberlist(), queue_function_queuewaitingcount(), random_exec(), read_exec(), readfile_exec(), realtime_exec(), realtime_update_exec(), record_exec(), retrydial_exec(), rqm_exec(), sayunixtime_exec(), senddtmf_exec(), sendimage_exec(), sendtext_exec(), sendurl_exec(), setcallerid_exec(), setcallerid_pres_exec(), setcdruserfield_exec(), settransfercapability_exec(), skel_exec(), smdi_msg_read(), smdi_msg_retrieve_read(), sms_exec(), softhangup_exec(), speech_activate(), speech_background(), speech_create(), speech_deactivate(), speech_destroy(), speech_load(), speech_processing_sound(), speech_start(), speech_unload(), stop_mixmonitor_exec(), system_exec_helper(), testclient_exec(), testserver_exec(), transfer_exec(), tryexec_exec(), upqm_exec(), userevent_exec(), verbose_exec(), vm_box_exists(), vm_exec(), vm_execmain(), vmauthenticate(), waitforring_exec(), and zapateller_exec().
#define ast_module_user_hangup_all | ( | ) | __ast_module_user_hangup_all(ast_module_info->self) |
#define ast_module_user_remove | ( | user | ) | __ast_module_user_remove(ast_module_info->self, user) |
Definition at line 221 of file module.h.
Referenced by _macro_exec(), acf_curl_exec(), acf_cut_exec(), acf_rand_exec(), acf_sort_exec(), acf_vmcount_exec(), admin_exec(), adsi_exec(), agi_exec_full(), alarmreceiver_exec(), amd_exec(), app_exec(), appendcdruserfield_exec(), aqm_exec(), asyncgoto_exec(), auth_exec(), background_detect_exec(), builtin_parkcall(), chanavail_exec(), chanspy_exec(), conf_exec(), controlplayback_exec(), count_exec(), cpeid_exec(), del_exec(), deltree_exec(), dictate_exec(), directory_exec(), disa_exec(), dumpchan_exec(), dundifunc_read(), echo_exec(), exec(), exec_exec(), execif_exec(), extenspy_exec(), festival_exec(), flash_exec(), function_enum(), function_realtime_read(), function_realtime_write(), function_txtcidname(), gosub_exec(), gosubif_exec(), hasvoicemail_exec(), ices_exec(), local_hangup(), log_exec(), lookupblacklist_exec(), lookupcidname_exec(), macroif_exec(), milliwatt_exec(), mixmonitor_exec(), morsecode_exec(), mp3_exec(), nbs_destroy(), NBScat_exec(), nocdr_exec(), ospauth_exec(), ospfinished_exec(), osplookup_exec(), ospnext_exec(), page_exec(), park_call_exec(), park_exec(), parkandannounce_exec(), pickup_exec(), playback_exec(), pqm_exec(), privacy_exec(), ql_exec(), queue_function_queuemembercount(), queue_function_queuememberlist(), queue_function_queuewaitingcount(), random_exec(), read_exec(), readfile_exec(), realtime_exec(), realtime_update_exec(), record_exec(), retrydial_exec(), rqm_exec(), sayunixtime_exec(), senddtmf_exec(), sendimage_exec(), sendtext_exec(), sendurl_exec(), setcallerid_exec(), setcallerid_pres_exec(), setcdruserfield_exec(), settransfercapability_exec(), skel_exec(), smdi_msg_read(), smdi_msg_retrieve_read(), sms_exec(), softhangup_exec(), speech_activate(), speech_background(), speech_create(), speech_deactivate(), speech_destroy(), speech_load(), speech_processing_sound(), speech_start(), speech_unload(), stop_mixmonitor_exec(), system_exec_helper(), testclient_exec(), testserver_exec(), transfer_exec(), tryexec_exec(), upqm_exec(), verbose_exec(), vm_box_exists(), vm_exec(), vm_execmain(), vmauthenticate(), waitforring_exec(), and zapateller_exec().
#define ASTERISK_GPL_KEY "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" |
enum ast_module_flags |
Definition at line 179 of file module.h.
00179 { 00180 AST_MODFLAG_DEFAULT = 0, 00181 AST_MODFLAG_GLOBAL_SYMBOLS = (1 << 0), 00182 AST_MODFLAG_BUILDSUM = (1 << 1), 00183 };
Definition at line 60 of file module.h.
00060 { 00061 AST_MODULE_LOAD_SUCCESS = 0, /*!< Module loaded and configured */ 00062 AST_MODULE_LOAD_DECLINE = 1, /*!< Module is not configured */ 00063 AST_MODULE_LOAD_SKIP = 2, /*!< Module was skipped for some reason */ 00064 AST_MODULE_LOAD_FAILURE = -1, /*!< Module could not be loaded properly */ 00065 };
Definition at line 53 of file module.h.
00053 { 00054 AST_FORCE_SOFT = 0, /*!< Softly unload a module, only if not in use */ 00055 AST_FORCE_FIRM = 1, /*!< Firmly unload a module, even if in use */ 00056 AST_FORCE_HARD = 2, /*!< as FIRM, plus dlclose() on the module. Not recommended 00057 as it may cause crashes */ 00058 };
struct ast_module_user* __ast_module_user_add | ( | struct ast_module * | , | |
struct ast_channel * | ||||
) |
Definition at line 184 of file loader.c.
References ast_atomic_fetchadd_int(), ast_calloc, AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_UNLOCK, ast_update_use_count(), ast_module_user::chan, ast_module_user::entry, ast_module::usecount, and ast_module::users.
00186 { 00187 struct ast_module_user *u = ast_calloc(1, sizeof(*u)); 00188 00189 if (!u) 00190 return NULL; 00191 00192 u->chan = chan; 00193 00194 AST_LIST_LOCK(&mod->users); 00195 AST_LIST_INSERT_HEAD(&mod->users, u, entry); 00196 AST_LIST_UNLOCK(&mod->users); 00197 00198 ast_atomic_fetchadd_int(&mod->usecount, +1); 00199 00200 ast_update_use_count(); 00201 00202 return u; 00203 }
void __ast_module_user_hangup_all | ( | struct ast_module * | ) |
Definition at line 216 of file loader.c.
References ast_atomic_fetchadd_int(), AST_LIST_LOCK, AST_LIST_REMOVE_HEAD, AST_LIST_UNLOCK, ast_softhangup(), AST_SOFTHANGUP_APPUNLOAD, ast_update_use_count(), ast_module_user::chan, ast_module_user::entry, free, ast_module::usecount, and ast_module::users.
Referenced by ast_unload_resource().
00217 { 00218 struct ast_module_user *u; 00219 00220 AST_LIST_LOCK(&mod->users); 00221 while ((u = AST_LIST_REMOVE_HEAD(&mod->users, entry))) { 00222 ast_softhangup(u->chan, AST_SOFTHANGUP_APPUNLOAD); 00223 ast_atomic_fetchadd_int(&mod->usecount, -1); 00224 free(u); 00225 } 00226 AST_LIST_UNLOCK(&mod->users); 00227 00228 ast_update_use_count(); 00229 }
void __ast_module_user_remove | ( | struct ast_module * | , | |
struct ast_module_user * | ||||
) |
Definition at line 205 of file loader.c.
References ast_atomic_fetchadd_int(), AST_LIST_LOCK, AST_LIST_REMOVE, AST_LIST_UNLOCK, ast_update_use_count(), ast_module_user::entry, free, ast_module::usecount, and ast_module::users.
00206 { 00207 AST_LIST_LOCK(&mod->users); 00208 AST_LIST_REMOVE(&mod->users, u, entry); 00209 AST_LIST_UNLOCK(&mod->users); 00210 ast_atomic_fetchadd_int(&mod->usecount, -1); 00211 free(u); 00212 00213 ast_update_use_count(); 00214 }
enum ast_module_load_result ast_load_resource | ( | const char * | resource_name | ) |
Load a module.
resource_name | The name of the module to load. |
Definition at line 781 of file loader.c.
References AST_LIST_LOCK, AST_LIST_UNLOCK, and load_resource().
Referenced by file_ok_sel(), handle_load(), handle_load_deprecated(), and reload().
00782 { 00783 AST_LIST_LOCK(&module_list); 00784 load_resource(resource_name, 0); 00785 AST_LIST_UNLOCK(&module_list); 00786 00787 return 0; 00788 }
int ast_loader_register | ( | int(*)(void) | updater | ) |
Add a procedure to be run when modules have been updated.
updater | The function to run when modules have been updated. |
Definition at line 1031 of file loader.c.
References AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_UNLOCK, and ast_malloc.
Referenced by show_console().
01032 { 01033 struct loadupdate *tmp; 01034 01035 if (!(tmp = ast_malloc(sizeof(*tmp)))) 01036 return -1; 01037 01038 tmp->updater = v; 01039 AST_LIST_LOCK(&updaters); 01040 AST_LIST_INSERT_HEAD(&updaters, tmp, entry); 01041 AST_LIST_UNLOCK(&updaters); 01042 01043 return 0; 01044 }
int ast_loader_unregister | ( | int(*)(void) | updater | ) |
Remove a procedure to be run when modules are updated.
updater | The updater function to unregister. |
Definition at line 1046 of file loader.c.
References AST_LIST_LOCK, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, and loadupdate::updater.
Referenced by exit_now().
01047 { 01048 struct loadupdate *cur; 01049 01050 AST_LIST_LOCK(&updaters); 01051 AST_LIST_TRAVERSE_SAFE_BEGIN(&updaters, cur, entry) { 01052 if (cur->updater == v) { 01053 AST_LIST_REMOVE_CURRENT(&updaters, entry); 01054 break; 01055 } 01056 } 01057 AST_LIST_TRAVERSE_SAFE_END; 01058 AST_LIST_UNLOCK(&updaters); 01059 01060 return cur ? 0 : -1; 01061 }
char* ast_module_helper | ( | const char * | line, | |
const char * | word, | |||
int | pos, | |||
int | state, | |||
int | rpos, | |||
int | needsreload | |||
) |
Match modules names for the Asterisk cli.
line | Unused by this function, but this should be the line we are matching. | |
word | The partial name to match. | |
pos | The position the word we are completing is in. | |
state | The possible match to return. | |
rpos | The position we should be matching. This should be the same as pos. | |
needsreload | This should be 1 if we need to reload this module and 0 otherwise. This function will only return modules that are reloadble if this is 1. |
Definition at line 517 of file loader.c.
References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_module_user::entry, ast_module::info, name, ast_module_info::reload, ast_module::resource, and strdup.
Referenced by complete_mod_2(), complete_mod_3(), complete_mod_3_nr(), complete_mod_4(), and load_module().
00518 { 00519 struct ast_module *cur; 00520 int i, which=0, l = strlen(word); 00521 char *ret = NULL; 00522 00523 if (pos != rpos) 00524 return NULL; 00525 00526 AST_LIST_LOCK(&module_list); 00527 AST_LIST_TRAVERSE(&module_list, cur, entry) { 00528 if (!strncasecmp(word, cur->resource, l) && 00529 (cur->info->reload || !needsreload) && 00530 ++which > state) { 00531 ret = strdup(cur->resource); 00532 break; 00533 } 00534 } 00535 AST_LIST_UNLOCK(&module_list); 00536 00537 if (!ret) { 00538 for (i=0; !ret && reload_classes[i].name; i++) { 00539 if (!strncasecmp(word, reload_classes[i].name, l) && ++which > state) 00540 ret = strdup(reload_classes[i].name); 00541 } 00542 } 00543 00544 return ret; 00545 }
struct ast_module* ast_module_ref | ( | struct ast_module * | ) |
Definition at line 1063 of file loader.c.
References ast_atomic_fetchadd_int(), ast_update_use_count(), and ast_module::usecount.
Referenced by __oh323_new(), alsa_new(), ast_iax2_new(), cli_audio_convert(), cli_audio_convert_deprecated(), complete_orig(), dahdi_new(), features_new(), fn_wrapper(), gtalk_new(), handle_orig(), mgcp_new(), newpvt(), oss_new(), phone_check_exception(), phone_new(), sip_new(), and skinny_new().
01064 { 01065 ast_atomic_fetchadd_int(&mod->usecount, +1); 01066 ast_update_use_count(); 01067 01068 return mod; 01069 }
void ast_module_register | ( | const struct ast_module_info * | ) |
Definition at line 122 of file loader.c.
References ast_calloc, AST_LIST_HEAD_INIT, AST_LIST_INSERT_TAIL, AST_LIST_LOCK, AST_LIST_UNLOCK, embedding, ast_module_user::entry, ast_module::info, resource_being_loaded, and ast_module::users.
00123 { 00124 struct ast_module *mod; 00125 00126 if (embedding) { 00127 if (!(mod = ast_calloc(1, sizeof(*mod) + strlen(info->name) + 1))) 00128 return; 00129 strcpy(mod->resource, info->name); 00130 } else { 00131 mod = resource_being_loaded; 00132 } 00133 00134 mod->info = info; 00135 AST_LIST_HEAD_INIT(&mod->users); 00136 00137 /* during startup, before the loader has been initialized, 00138 there are no threads, so there is no need to take the lock 00139 on this list to manipulate it. it is also possible that it 00140 might be unsafe to use the list lock at that point... so 00141 let's avoid it altogether 00142 */ 00143 if (!embedding) 00144 AST_LIST_LOCK(&module_list); 00145 00146 /* it is paramount that the new entry be placed at the tail of 00147 the list, otherwise the code that uses dlopen() to load 00148 dynamic modules won't be able to find out if the module it 00149 just opened was registered or failed to load 00150 */ 00151 AST_LIST_INSERT_TAIL(&module_list, mod, entry); 00152 00153 if (!embedding) 00154 AST_LIST_UNLOCK(&module_list); 00155 00156 /* give the module a copy of its own handle, for later use in registrations and the like */ 00157 *((struct ast_module **) &(info->self)) = mod; 00158 }
void ast_module_shutdown | ( | void | ) |
Run the unload() callback for all loaded modules.
This function should be called when Asterisk is shutting down gracefully.
Definition at line 431 of file loader.c.
References AST_LIST_HEAD_DESTROY, AST_LIST_HEAD_NOLOCK_STATIC, AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_REMOVE_HEAD, AST_LIST_UNLOCK, ast_module_user::entry, free, ast_module::info, ast_module_info::unload, and ast_module::users.
Referenced by quit_handler().
00432 { 00433 struct ast_module *mod; 00434 AST_LIST_HEAD_NOLOCK_STATIC(local_module_list, ast_module); 00435 00436 /* We have to call the unload() callbacks in reverse order that the modules 00437 * exist in the module list so it is the reverse order of how they were 00438 * loaded. */ 00439 00440 AST_LIST_LOCK(&module_list); 00441 while ((mod = AST_LIST_REMOVE_HEAD(&module_list, entry))) 00442 AST_LIST_INSERT_HEAD(&local_module_list, mod, entry); 00443 AST_LIST_UNLOCK(&module_list); 00444 00445 while ((mod = AST_LIST_REMOVE_HEAD(&local_module_list, entry))) { 00446 if (mod->info->unload) 00447 mod->info->unload(); 00448 /* Since this should only be called when shutting down "gracefully", 00449 * all channels should be down before we get to this point, meaning 00450 * there will be no module users left. */ 00451 AST_LIST_HEAD_DESTROY(&mod->users); 00452 free(mod); 00453 } 00454 }
void ast_module_unref | ( | struct ast_module * | ) |
Definition at line 1071 of file loader.c.
References ast_atomic_fetchadd_int(), ast_update_use_count(), and ast_module::usecount.
Referenced by alsa_hangup(), ast_smdi_interface_destroy(), cli_audio_convert(), cli_audio_convert_deprecated(), complete_orig(), dahdi_destroy_channel_bynum(), dahdi_hangup(), destroy(), filestream_destructor(), gtalk_hangup(), handle_orig(), iax2_predestroy(), mgcp_hangup(), oh323_hangup(), oss_hangup(), phone_check_exception(), phone_hangup(), and sip_hangup().
01072 { 01073 ast_atomic_fetchadd_int(&mod->usecount, -1); 01074 ast_update_use_count(); 01075 }
void ast_module_unregister | ( | const struct ast_module_info * | ) |
Definition at line 160 of file loader.c.
References AST_LIST_HEAD_DESTROY, AST_LIST_LOCK, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, ast_module_user::entry, free, ast_module::info, and ast_module::users.
00161 { 00162 struct ast_module *mod = NULL; 00163 00164 /* it is assumed that the users list in the module structure 00165 will already be empty, or we cannot have gotten to this 00166 point 00167 */ 00168 AST_LIST_LOCK(&module_list); 00169 AST_LIST_TRAVERSE_SAFE_BEGIN(&module_list, mod, entry) { 00170 if (mod->info == info) { 00171 AST_LIST_REMOVE_CURRENT(&module_list, entry); 00172 break; 00173 } 00174 } 00175 AST_LIST_TRAVERSE_SAFE_END; 00176 AST_LIST_UNLOCK(&module_list); 00177 00178 if (mod) { 00179 AST_LIST_HEAD_DESTROY(&mod->users); 00180 free(mod); 00181 } 00182 }
int ast_unload_resource | ( | const char * | resource_name, | |
enum | ast_module_unload_mode | |||
) |
Unload a module.
resource_name | The name of the module to unload. | |
ast_module_unload_mode | The force flag. This should be set using one of the AST_FORCE flags. |
Definition at line 456 of file loader.c.
References __ast_module_user_hangup_all(), AST_FORCE_FIRM, AST_LIST_LOCK, AST_LIST_UNLOCK, ast_log(), ast_update_use_count(), ast_module::declined, find_resource(), ast_module::flags, ast_module::lib, LOG_WARNING, ast_module::running, unload_dynamic_module(), and ast_module::usecount.
Referenced by exit_now(), handle_unload(), handle_unload_deprecated(), reload(), and remove_module().
00457 { 00458 struct ast_module *mod; 00459 int res = -1; 00460 int error = 0; 00461 00462 AST_LIST_LOCK(&module_list); 00463 00464 if (!(mod = find_resource(resource_name, 0))) { 00465 AST_LIST_UNLOCK(&module_list); 00466 return 0; 00467 } 00468 00469 if (!(mod->flags.running || mod->flags.declined)) 00470 error = 1; 00471 00472 if (!mod->lib) { 00473 ast_log(LOG_WARNING, "Unloading embedded modules is not supported.\n"); 00474 error = 1; 00475 } 00476 00477 if (!error && (mod->usecount > 0)) { 00478 if (force) 00479 ast_log(LOG_WARNING, "Warning: Forcing removal of module '%s' with use count %d\n", 00480 resource_name, mod->usecount); 00481 else { 00482 ast_log(LOG_WARNING, "Soft unload failed, '%s' has use count %d\n", resource_name, 00483 mod->usecount); 00484 error = 1; 00485 } 00486 } 00487 00488 if (!error) { 00489 __ast_module_user_hangup_all(mod); 00490 res = mod->info->unload(); 00491 00492 if (res) { 00493 ast_log(LOG_WARNING, "Firm unload failed for %s\n", resource_name); 00494 if (force <= AST_FORCE_FIRM) 00495 error = 1; 00496 else 00497 ast_log(LOG_WARNING, "** Dangerous **: Unloading resource anyway, at user request\n"); 00498 } 00499 } 00500 00501 if (!error) 00502 mod->flags.running = mod->flags.declined = 0; 00503 00504 AST_LIST_UNLOCK(&module_list); 00505 00506 #ifdef LOADABLE_MODULES 00507 if (!error) 00508 unload_dynamic_module(mod); 00509 #endif 00510 00511 if (!error) 00512 ast_update_use_count(); 00513 00514 return res; 00515 }
int ast_update_module_list | ( | int(*)(const char *module, const char *description, int usecnt, const char *like) | modentry, | |
const char * | like | |||
) |
Ask for a list of modules, descriptions, and use counts.
modentry | A callback to an updater function. | |
like | For each of the modules loaded, modentry will be executed with the resource, description, and usecount values of each particular module. |
Definition at line 1011 of file loader.c.
References AST_LIST_TRAVERSE, AST_LIST_TRYLOCK, AST_LIST_UNLOCK, ast_module_info::description, ast_module::info, ast_module::resource, and ast_module::usecount.
Referenced by handle_modlist(), and mod_update().
01013 { 01014 struct ast_module *cur; 01015 int unlock = -1; 01016 int total_mod_loaded = 0; 01017 01018 if (AST_LIST_TRYLOCK(&module_list)) 01019 unlock = 0; 01020 01021 AST_LIST_TRAVERSE(&module_list, cur, entry) { 01022 total_mod_loaded += modentry(cur->resource, cur->info->description, cur->usecount, like); 01023 } 01024 01025 if (unlock) 01026 AST_LIST_UNLOCK(&module_list); 01027 01028 return total_mod_loaded; 01029 }
void ast_update_use_count | ( | void | ) |
Notify when usecount has been changed.
This function calulates use counts and notifies anyone trying to keep track of them. It should be called whenever your module's usecount changes.
Definition at line 999 of file loader.c.
References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, and loadupdate::updater.
Referenced by __ast_module_user_add(), __ast_module_user_hangup_all(), __ast_module_user_remove(), agent_new(), ast_module_ref(), ast_module_unref(), ast_unload_resource(), exit_now(), load_module(), load_resource(), oh323_request(), sip_request_call(), and sipsock_read().
01000 { 01001 /* Notify any module monitors that the use count for a 01002 resource has changed */ 01003 struct loadupdate *m; 01004 01005 AST_LIST_LOCK(&updaters); 01006 AST_LIST_TRAVERSE(&updaters, m, entry) 01007 m->updater(); 01008 AST_LIST_UNLOCK(&updaters); 01009 }
const struct ast_module_info* ast_module_info [static] |