Because of the (often recursive) nature of module dependencies in
Asterisk, hot swapping a module on the fly is cumbersome if a module
is depended on by other modules. Currently, dependencies must be
popped manually by unloading dependents, unloading the module of
interest, and then loading modules again in reverse order.
To make this easier, the ability to do this recursively in certain
circumstances has been added, as an optional extension to the
"module refresh" command. If requested, Asterisk will check if a module
that has a positive usecount could be unloaded safely if anything
recursively dependent on it were unloaded. If so, it will go ahead
and unload all these modules and load them back again. This makes
hot swapping modules that provide dependencies much easier.
Resolves: #474
UserNote: In certain circumstances, modules with dependency relations
can have their dependents automatically recursively unloaded and loaded
again using the "module refresh" CLI command or the ModuleLoad AMI command.
revert-549-master-issue-548
Naveen Albert1 year agocommitted byasterisk-org-access-app[bot]
ast_log(LOG_NOTICE,"Can't unload %s right now because %s is dependent on it\n",ast_module_name(target),ast_module_name(mod));
return0;
}
/* Insert at beginning, so later if we're loading modules again automatically, we can do so in the same order. */
name=ast_strdup(ast_module_name(mod));
if(!name){
return0;
}
ast_debug(3,"Found new dependent %s\n",ast_module_name(mod));
if(AST_VECTOR_INSERT_AT(dependents,0,name)){
ast_log(LOG_ERROR,"Failed to add module '%s' to vector\n",ast_module_name(mod));
return0;
}
if(!--usecount){
break;
}
}
}
if(usecount){
ast_log(LOG_NOTICE,"Module %s cannot be unloaded (would still have use count %d/%d after unloading dependents)\n",ast_module_name(target),usecount,target->usecount);