<p>Corey Farrell has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/6958">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Prevent unload of modules which implement an Optional API.<br><br>Once an Optional API module is loaded it should stay loaded. Unloading<br>an optional API module runs the risk of a crash if something else is<br>using it. This patch causes all optional API providers to tell the<br>module loader not to unload except at shutdown.<br><br>ASTERISK-27389<br><br>Change-Id: Ia07786fe655681aec49cc8d3d96e06483b11f5e6<br>---<br>M funcs/func_periodic_hook.c<br>M res/res_agi.c<br>M res/res_http_websocket.c<br>M res/res_monitor.c<br>M res/res_pktccops.c<br>M res/res_smdi.c<br>M res/res_statsd.c<br>7 files changed, 26 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/58/6958/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/funcs/func_periodic_hook.c b/funcs/func_periodic_hook.c<br>index f8e79b3..0ab3d6b 100644<br>--- a/funcs/func_periodic_hook.c<br>+++ b/funcs/func_periodic_hook.c<br>@@ -488,6 +488,11 @@<br> <br> res = ast_custom_function_register_escalating(&hook_function, AST_CFE_BOTH);<br> <br>+ if (!res) {<br>+ /* For Optional API. */<br>+ ast_module_shutdown_ref(AST_MODULE_SELF);<br>+ }<br>+<br> return res ? AST_MODULE_LOAD_DECLINE : AST_MODULE_LOAD_SUCCESS;<br> }<br> <br>diff --git a/res/res_agi.c b/res/res_agi.c<br>index 4660635..91f270c 100644<br>--- a/res/res_agi.c<br>+++ b/res/res_agi.c<br>@@ -4713,6 +4713,10 @@<br> unload_module();<br> return AST_MODULE_LOAD_DECLINE;<br> }<br>+<br>+ /* For Optional API. */<br>+ ast_module_shutdown_ref(AST_MODULE_SELF);<br>+<br> return AST_MODULE_LOAD_SUCCESS;<br> }<br> <br>diff --git a/res/res_http_websocket.c b/res/res_http_websocket.c<br>index 60332f5..8e9aae9 100644<br>--- a/res/res_http_websocket.c<br>+++ b/res/res_http_websocket.c<br>@@ -1446,6 +1446,9 @@<br> ast_http_uri_link(&websocketuri);<br> websocket_add_protocol_internal("echo", websocket_echo_callback);<br> <br>+ /* For Optional API. */<br>+ ast_module_shutdown_ref(AST_MODULE_SELF);<br>+<br> return 0;<br> }<br> <br>diff --git a/res/res_monitor.c b/res/res_monitor.c<br>index 3e3611b..aed5a26 100644<br>--- a/res/res_monitor.c<br>+++ b/res/res_monitor.c<br>@@ -984,6 +984,9 @@<br> ast_manager_register_xml("PauseMonitor", EVENT_FLAG_CALL, pause_monitor_action);<br> ast_manager_register_xml("UnpauseMonitor", EVENT_FLAG_CALL, unpause_monitor_action);<br> <br>+ /* For Optional API. */<br>+ ast_module_shutdown_ref(AST_MODULE_SELF);<br>+<br> return AST_MODULE_LOAD_SUCCESS;<br> }<br> <br>diff --git a/res/res_pktccops.c b/res/res_pktccops.c<br>index 4f69448..e8d266c 100644<br>--- a/res/res_pktccops.c<br>+++ b/res/res_pktccops.c<br>@@ -1472,6 +1472,10 @@<br> }<br> ast_cli_register_multiple(cli_pktccops, sizeof(cli_pktccops) / sizeof(struct ast_cli_entry));<br> restart_pktc_thread();<br>+<br>+ /* For Optional API. */<br>+ ast_module_shutdown_ref(AST_MODULE_SELF);<br>+<br> return 0;<br> }<br> <br>diff --git a/res/res_smdi.c b/res/res_smdi.c<br>index 4d72401..0edabb8 100644<br>--- a/res/res_smdi.c<br>+++ b/res/res_smdi.c<br>@@ -1405,6 +1405,10 @@<br> }<br> <br> smdi_loaded = 0;<br>+<br>+ /* For Optional API. */<br>+ ast_module_shutdown_ref(AST_MODULE_SELF);<br>+<br> return 0;<br> }<br> <br>diff --git a/res/res_statsd.c b/res/res_statsd.c<br>index 3d7dd16..aee0bcd 100644<br>--- a/res/res_statsd.c<br>+++ b/res/res_statsd.c<br>@@ -353,6 +353,9 @@<br> return AST_MODULE_LOAD_DECLINE;<br> }<br> <br>+ /* For Optional API. */<br>+ ast_module_shutdown_ref(AST_MODULE_SELF);<br>+<br> return AST_MODULE_LOAD_SUCCESS;<br> }<br> <br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/6958">change 6958</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/6958"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 15 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Ia07786fe655681aec49cc8d3d96e06483b11f5e6 </div>
<div style="display:none"> Gerrit-Change-Number: 6958 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>