From 79f111e1f317fffd3222b70c31a0fac65c40234e Mon Sep 17 00:00:00 2001 From: Corey Farrell Date: Wed, 1 Nov 2017 20:46:11 -0400 Subject: Prevent unload of modules which implement an Optional API. Once an Optional API module is loaded it should stay loaded. Unloading an optional API module runs the risk of a crash if something else is using it. This patch causes all optional API providers to tell the module loader not to unload except at shutdown. ASTERISK-27389 Change-Id: Ia07786fe655681aec49cc8d3d96e06483b11f5e6 --- funcs/func_periodic_hook.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'funcs/func_periodic_hook.c') diff --git a/funcs/func_periodic_hook.c b/funcs/func_periodic_hook.c index f8e79b326..0ab3d6b8b 100644 --- a/funcs/func_periodic_hook.c +++ b/funcs/func_periodic_hook.c @@ -488,6 +488,11 @@ static int load_module(void) res = ast_custom_function_register_escalating(&hook_function, AST_CFE_BOTH); + if (!res) { + /* For Optional API. */ + ast_module_shutdown_ref(AST_MODULE_SELF); + } + return res ? AST_MODULE_LOAD_DECLINE : AST_MODULE_LOAD_SUCCESS; } -- cgit v1.2.3