<p>Jenkins2 <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/6959">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  George Joseph: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved
  Jenkins2: Approved for Submit

</div><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;">diff --git a/funcs/func_periodic_hook.c b/funcs/func_periodic_hook.c<br>index f459e35..0e260c9 100644<br>--- a/funcs/func_periodic_hook.c<br>+++ b/funcs/func_periodic_hook.c<br>@@ -490,6 +490,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_info->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 d7ea351..d104c43 100644<br>--- a/res/res_agi.c<br>+++ b/res/res_agi.c<br>@@ -4715,6 +4715,10 @@<br>           unload_module();<br>              return AST_MODULE_LOAD_DECLINE;<br>       }<br>+<br>+ /* For Optional API. */<br>+      ast_module_shutdown_ref(ast_module_info->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 f49a357..2baccc0 100644<br>--- a/res/res_http_websocket.c<br>+++ b/res/res_http_websocket.c<br>@@ -1439,6 +1439,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_info->self);<br>+<br>         return 0;<br> }<br> <br>diff --git a/res/res_monitor.c b/res/res_monitor.c<br>index c4ee674..b7ef2ea 100644<br>--- a/res/res_monitor.c<br>+++ b/res/res_monitor.c<br>@@ -987,6 +987,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_info->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 837e0f5..037e533 100644<br>--- a/res/res_pktccops.c<br>+++ b/res/res_pktccops.c<br>@@ -1474,6 +1474,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_info->self);<br>+<br>         return 0;<br> }<br> <br>diff --git a/res/res_smdi.c b/res/res_smdi.c<br>index 9a40227..7b4c42b 100644<br>--- a/res/res_smdi.c<br>+++ b/res/res_smdi.c<br>@@ -1407,6 +1407,10 @@<br>     }<br> <br>  smdi_loaded = 0;<br>+<br>+  /* For Optional API. */<br>+      ast_module_shutdown_ref(ast_module_info->self);<br>+<br>         return 0;<br> }<br> <br>diff --git a/res/res_statsd.c b/res/res_statsd.c<br>index eb0dc67..b8e4d04 100644<br>--- a/res/res_statsd.c<br>+++ b/res/res_statsd.c<br>@@ -355,6 +355,9 @@<br>                return AST_MODULE_LOAD_DECLINE;<br>       }<br> <br>+ /* For Optional API. */<br>+      ast_module_shutdown_ref(ast_module_info->self);<br>+<br>         return AST_MODULE_LOAD_SUCCESS;<br> }<br> <br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/6959">change 6959</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/6959"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: Ia07786fe655681aec49cc8d3d96e06483b11f5e6 </div>
<div style="display:none"> Gerrit-Change-Number: 6959 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>