Fix shutdown crash caused by modules being left open.

It is only safe to run ast_register_cleanup callbacks when all modules
have been unloaded.  Previously these callbacks were run during graceful
shutdown, making it possible to crash during shutdown.

ASTERISK-26513 #close

Change-Id: Ibfa635bb688d1227ec54aa211d90d6bd45052e21
This commit is contained in:
Corey Farrell
2016-10-27 22:49:43 -04:00
parent 0ec5abe592
commit d6ad867897
4 changed files with 8 additions and 10 deletions

View File

@@ -607,7 +607,7 @@ static struct ast_module *load_dynamic_module(const char *resource_in, unsigned
#endif
void ast_module_shutdown(void)
int modules_shutdown(void)
{
struct ast_module *mod;
int somethingchanged = 1, final = 0;
@@ -655,7 +655,10 @@ void ast_module_shutdown(void)
}
} while (somethingchanged && !final);
final = AST_DLLIST_EMPTY(&module_list);
AST_DLLIST_UNLOCK(&module_list);
return !final;
}
int ast_unload_resource(const char *resource_name, enum ast_module_unload_mode force)