#include "asterisk/utils.h"
Include dependency graph for module.h:
This graph shows which files directly or indirectly include this file:
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) } |
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 *) |
static const | __attribute__ ((unused)) struct ast_module_info *ast_module_info |
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. | |
int | ast_module_check (char *name) |
Check if module with the name given is loaded. | |
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_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. |
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 215 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_conference_main(), 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(), execif_exec(), extenspy_exec(), festival_exec(), flash_exec(), forkcdr_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(), mwanalyze_exec(), MYSQL_exec(), nbs_new(), NBScat_exec(), nocdr_exec(), nv_background_detect_exec(), nv_detectfax_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_qac(), queue_function_queuememberlist(), queue_function_queuewaitingcount(), random_exec(), read_exec(), readfile_exec(), realtime_exec(), realtime_update_exec(), record_exec(), retrydial_exec(), rpt_exec(), rqm_exec(), rxfax_exec(), sayunixtime_exec(), segfault_exec(), senddtmf_exec(), sendimage_exec(), sendtext_exec(), sendurl_exec(), setcallerid_exec(), setcallerid_pres_exec(), setcdruserfield_exec(), settransfercapability_exec(), skel_exec(), 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(), txfax_exec(), upqm_exec(), userevent_exec(), verbose_exec(), vm_box_exists(), vm_exec(), vm_execmain(), vmauthenticate(), waitforring_exec(), zapateller_exec(), and zapras_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 216 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_conference_main(), 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(), execif_exec(), extenspy_exec(), festival_exec(), flash_exec(), forkcdr_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(), mwanalyze_exec(), MYSQL_exec(), nbs_destroy(), NBScat_exec(), nocdr_exec(), nv_background_detect_exec(), nv_detectfax_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_qac(), queue_function_queuememberlist(), queue_function_queuewaitingcount(), random_exec(), read_exec(), readfile_exec(), realtime_exec(), realtime_update_exec(), record_exec(), retrydial_exec(), rqm_exec(), rxfax_exec(), sayunixtime_exec(), segfault_exec(), senddtmf_exec(), sendimage_exec(), sendtext_exec(), sendurl_exec(), setcallerid_exec(), setcallerid_pres_exec(), setcdruserfield_exec(), settransfercapability_exec(), skel_exec(), 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(), txfax_exec(), upqm_exec(), userevent_exec(), verbose_exec(), vm_box_exists(), vm_exec(), vm_execmain(), vmauthenticate(), waitforring_exec(), zapateller_exec(), and zapras_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 };
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 };
AST_FORCE_SOFT | Softly unload a module, only if not in use |
AST_FORCE_FIRM | Firmly unload a module, even if in use |
AST_FORCE_HARD | as FIRM, plus dlclose() on the module. Not recommended as it may cause crashes |
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 177 of file loader.c.
References ast_calloc, AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_UNLOCK, ast_update_use_count(), ast_module_user::chan, ast_module::usecount, and ast_module::users.
00179 { 00180 struct ast_module_user *u = ast_calloc(1, sizeof(*u)); 00181 00182 if (!u) 00183 return NULL; 00184 00185 u->chan = chan; 00186 00187 AST_LIST_LOCK(&mod->users); 00188 AST_LIST_INSERT_HEAD(&mod->users, u, entry); 00189 AST_LIST_UNLOCK(&mod->users); 00190 00191 ast_atomic_fetchadd_int(&mod->usecount, +1); 00192 00193 ast_update_use_count(); 00194 00195 return u; 00196 }
void __ast_module_user_hangup_all | ( | struct ast_module * | ) |
Definition at line 209 of file loader.c.
References AST_LIST_LOCK, AST_LIST_REMOVE_HEAD, AST_LIST_UNLOCK, ast_softhangup(), AST_SOFTHANGUP_APPUNLOAD, ast_update_use_count(), ast_module_user::chan, free, ast_module::usecount, and ast_module::users.
Referenced by ast_unload_resource().
00210 { 00211 struct ast_module_user *u; 00212 00213 AST_LIST_LOCK(&mod->users); 00214 while ((u = AST_LIST_REMOVE_HEAD(&mod->users, entry))) { 00215 ast_softhangup(u->chan, AST_SOFTHANGUP_APPUNLOAD); 00216 ast_atomic_fetchadd_int(&mod->usecount, -1); 00217 free(u); 00218 } 00219 AST_LIST_UNLOCK(&mod->users); 00220 00221 ast_update_use_count(); 00222 }
void __ast_module_user_remove | ( | struct ast_module * | , | |
struct ast_module_user * | ||||
) |
Definition at line 198 of file loader.c.
References AST_LIST_LOCK, AST_LIST_REMOVE, AST_LIST_UNLOCK, ast_update_use_count(), free, ast_module::usecount, and ast_module::users.
00199 { 00200 AST_LIST_LOCK(&mod->users); 00201 AST_LIST_REMOVE(&mod->users, u, entry); 00202 AST_LIST_UNLOCK(&mod->users); 00203 ast_atomic_fetchadd_int(&mod->usecount, -1); 00204 free(u); 00205 00206 ast_update_use_count(); 00207 }
static const __attribute__ | ( | (unused) | ) | [static] |
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 666 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_module().
00667 { 00668 AST_LIST_LOCK(&module_list); 00669 load_resource(resource_name, 0); 00670 AST_LIST_UNLOCK(&module_list); 00671 00672 return 0; 00673 }
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 908 of file loader.c.
References AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_UNLOCK, and ast_malloc.
Referenced by show_console().
00909 { 00910 struct loadupdate *tmp; 00911 00912 if (!(tmp = ast_malloc(sizeof(*tmp)))) 00913 return -1; 00914 00915 tmp->updater = v; 00916 AST_LIST_LOCK(&module_list); 00917 AST_LIST_INSERT_HEAD(&updaters, tmp, entry); 00918 AST_LIST_UNLOCK(&module_list); 00919 00920 return 0; 00921 }
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 923 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().
00924 { 00925 struct loadupdate *cur; 00926 00927 AST_LIST_LOCK(&module_list); 00928 AST_LIST_TRAVERSE_SAFE_BEGIN(&updaters, cur, entry) { 00929 if (cur->updater == v) { 00930 AST_LIST_REMOVE_CURRENT(&updaters, entry); 00931 break; 00932 } 00933 } 00934 AST_LIST_TRAVERSE_SAFE_END; 00935 AST_LIST_UNLOCK(&module_list); 00936 00937 return cur ? 0 : -1; 00938 }
int ast_module_check | ( | char * | name | ) |
Check if module with the name given is loaded.
name | Module name, like "chan_sip.so" |
Definition at line 889 of file loader.c.
References AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_mutex_trylock(), and ast_strlen_zero().
Referenced by ifmodule_read().
00890 { 00891 struct ast_module *cur; 00892 int unlock = -1; 00893 int res = 0; 00894 00895 if (ast_strlen_zero(name)) 00896 return 0; /* FALSE */ 00897 00898 if (ast_mutex_trylock(&module_list.lock)) 00899 unlock = 0; 00900 AST_LIST_TRAVERSE(&module_list, cur, entry) 00901 if (!res && !strcasecmp(name, cur->resource)) 00902 res = 1; 00903 if (unlock) 00904 AST_LIST_UNLOCK(&module_list); 00905 return res; 00906 }
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 491 of file loader.c.
References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_module::info, name, ast_module_info::reload, and strdup.
Referenced by complete_mod_2(), complete_mod_3(), complete_mod_3_nr(), and complete_mod_4().
00492 { 00493 struct ast_module *cur; 00494 int i, which=0, l = strlen(word); 00495 char *ret = NULL; 00496 00497 if (pos != rpos) 00498 return NULL; 00499 00500 AST_LIST_LOCK(&module_list); 00501 AST_LIST_TRAVERSE(&module_list, cur, entry) { 00502 if (!strncasecmp(word, cur->resource, l) && 00503 (cur->info->reload || !needsreload) && 00504 ++which > state) { 00505 ret = strdup(cur->resource); 00506 break; 00507 } 00508 } 00509 AST_LIST_UNLOCK(&module_list); 00510 00511 if (!ret) { 00512 for (i=0; !ret && reload_classes[i].name; i++) { 00513 if (!strncasecmp(word, reload_classes[i].name, l) && ++which > state) 00514 ret = strdup(reload_classes[i].name); 00515 } 00516 } 00517 00518 return ret; 00519 }
struct ast_module* ast_module_ref | ( | struct ast_module * | ) |
Definition at line 940 of file loader.c.
References 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(), features_new(), fn_wrapper(), gtalk_new(), handle_orig(), mgcp_new(), newpvt(), oss_new(), phone_check_exception(), phone_new(), sip_new(), skinny_new(), and zt_new().
00941 { 00942 ast_atomic_fetchadd_int(&mod->usecount, +1); 00943 ast_update_use_count(); 00944 00945 return mod; 00946 }
void ast_module_register | ( | const struct ast_module_info * | ) |
Definition at line 115 of file loader.c.
References ast_calloc, AST_LIST_HEAD_INIT, AST_LIST_INSERT_TAIL, AST_LIST_LOCK, AST_LIST_UNLOCK, embedding, ast_module::info, ast_module_info::name, resource_being_loaded, ast_module_info::self, and ast_module::users.
00116 { 00117 struct ast_module *mod; 00118 00119 if (embedding) { 00120 if (!(mod = ast_calloc(1, sizeof(*mod) + strlen(info->name) + 1))) 00121 return; 00122 strcpy(mod->resource, info->name); 00123 } else { 00124 mod = resource_being_loaded; 00125 } 00126 00127 mod->info = info; 00128 AST_LIST_HEAD_INIT(&mod->users); 00129 00130 /* during startup, before the loader has been initialized, 00131 there are no threads, so there is no need to take the lock 00132 on this list to manipulate it. it is also possible that it 00133 might be unsafe to use the list lock at that point... so 00134 let's avoid it altogether 00135 */ 00136 if (!embedding) 00137 AST_LIST_LOCK(&module_list); 00138 00139 /* it is paramount that the new entry be placed at the tail of 00140 the list, otherwise the code that uses dlopen() to load 00141 dynamic modules won't be able to find out if the module it 00142 just opened was registered or failed to load 00143 */ 00144 AST_LIST_INSERT_TAIL(&module_list, mod, entry); 00145 00146 if (!embedding) 00147 AST_LIST_UNLOCK(&module_list); 00148 00149 /* give the module a copy of its own handle, for later use in registrations and the like */ 00150 *((struct ast_module **) &(info->self)) = mod; 00151 }
void ast_module_unref | ( | struct ast_module * | ) |
Definition at line 948 of file loader.c.
References ast_update_use_count(), and ast_module::usecount.
Referenced by alsa_hangup(), ast_closestream(), ast_smdi_interface_destroy(), cli_audio_convert(), cli_audio_convert_deprecated(), complete_orig(), destroy(), gtalk_hangup(), handle_orig(), iax2_predestroy(), mgcp_hangup(), oh323_hangup(), oss_hangup(), phone_check_exception(), phone_hangup(), sip_hangup(), and zt_hangup().
00949 { 00950 ast_atomic_fetchadd_int(&mod->usecount, -1); 00951 ast_update_use_count(); 00952 }
void ast_module_unregister | ( | const struct ast_module_info * | ) |
Definition at line 153 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, free, ast_module::info, and ast_module::users.
00154 { 00155 struct ast_module *mod = NULL; 00156 00157 /* it is assumed that the users list in the module structure 00158 will already be empty, or we cannot have gotten to this 00159 point 00160 */ 00161 AST_LIST_LOCK(&module_list); 00162 AST_LIST_TRAVERSE_SAFE_BEGIN(&module_list, mod, entry) { 00163 if (mod->info == info) { 00164 AST_LIST_REMOVE_CURRENT(&module_list, entry); 00165 break; 00166 } 00167 } 00168 AST_LIST_TRAVERSE_SAFE_END; 00169 AST_LIST_UNLOCK(&module_list); 00170 00171 if (mod) { 00172 AST_LIST_HEAD_DESTROY(&mod->users); 00173 free(mod); 00174 } 00175 }
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 430 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, error(), find_resource(), ast_module::flags, ast_module::lib, ast_module::running, and ast_module::usecount.
Referenced by exit_now(), handle_unload(), handle_unload_deprecated(), reload_module(), and remove_module().
00431 { 00432 struct ast_module *mod; 00433 int res = -1; 00434 int error = 0; 00435 00436 AST_LIST_LOCK(&module_list); 00437 00438 if (!(mod = find_resource(resource_name, 0))) { 00439 AST_LIST_UNLOCK(&module_list); 00440 return 0; 00441 } 00442 00443 if (!(mod->flags.running || mod->flags.declined)) 00444 error = 1; 00445 00446 if (!mod->lib) { 00447 ast_log(LOG_WARNING, "Unloading embedded modules is not supported.\n"); 00448 error = 1; 00449 } 00450 00451 if (!error && (mod->usecount > 0)) { 00452 if (force) 00453 ast_log(LOG_WARNING, "Warning: Forcing removal of module '%s' with use count %d\n", 00454 resource_name, mod->usecount); 00455 else { 00456 ast_log(LOG_WARNING, "Soft unload failed, '%s' has use count %d\n", resource_name, 00457 mod->usecount); 00458 error = 1; 00459 } 00460 } 00461 00462 if (!error) { 00463 __ast_module_user_hangup_all(mod); 00464 res = mod->info->unload(); 00465 00466 if (res) { 00467 ast_log(LOG_WARNING, "Firm unload failed for %s\n", resource_name); 00468 if (force <= AST_FORCE_FIRM) 00469 error = 1; 00470 else 00471 ast_log(LOG_WARNING, "** Dangerous **: Unloading resource anyway, at user request\n"); 00472 } 00473 } 00474 00475 if (!error) 00476 mod->flags.running = mod->flags.declined = 0; 00477 00478 AST_LIST_UNLOCK(&module_list); 00479 00480 #if LOADABLE_MODULES 00481 if (!error) 00482 unload_dynamic_module(mod); 00483 #endif 00484 00485 if (!error) 00486 ast_update_use_count(); 00487 00488 return res; 00489 }
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 869 of file loader.c.
References AST_LIST_TRAVERSE, AST_LIST_TRYLOCK, AST_LIST_UNLOCK, ast_module_info::description, ast_module::info, and ast_module::usecount.
Referenced by handle_modlist(), and mod_update().
00871 { 00872 struct ast_module *cur; 00873 int unlock = -1; 00874 int total_mod_loaded = 0; 00875 00876 if (AST_LIST_TRYLOCK(&module_list)) 00877 unlock = 0; 00878 00879 AST_LIST_TRAVERSE(&module_list, cur, entry) { 00880 total_mod_loaded += modentry(cur->resource, cur->info->description, cur->usecount, like); 00881 } 00882 00883 if (unlock) 00884 AST_LIST_UNLOCK(&module_list); 00885 00886 return total_mod_loaded; 00887 }
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 857 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().
00858 { 00859 /* Notify any module monitors that the use count for a 00860 resource has changed */ 00861 struct loadupdate *m; 00862 00863 AST_LIST_LOCK(&module_list); 00864 AST_LIST_TRAVERSE(&updaters, m, entry) 00865 m->updater(); 00866 AST_LIST_UNLOCK(&module_list); 00867 }