<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/19486">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span></span><br></pre><div style="white-space:pre-wrap">Approvals:
George Joseph: Looks good to me, approved
Friendly Automation: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip_pubsub: Prevent removing subscriptions.<br><br>pjproject does not provide any mechanism of removing<br>event packages, which means that once a subscription<br>handler is registered, it is effectively permanent.<br><br>pjproject will assert if the same event package is<br>ever registered again, so currently unloading and<br>loading any Asterisk modules that use subscriptions<br>will cause a crash that is beyond our control.<br><br>For that reason, we now prevent users from being<br>able to unload these modules, to prevent them<br>from ever being loaded twice.<br><br>ASTERISK-30264 #close<br><br>Change-Id: I7fdcb1a5e44d38b7ba10c44259fe98f0ae9bc12c<br>---<br>M res/res_pjsip_exten_state.c<br>M res/res_pjsip_mwi.c<br>2 files changed, 50 insertions(+), 0 deletions(-)<br><br></pre>
<pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_pjsip_exten_state.c b/res/res_pjsip_exten_state.c</span><br><span>index 3c7baee..1b29091 100644</span><br><span>--- a/res/res_pjsip_exten_state.c</span><br><span>+++ b/res/res_pjsip_exten_state.c</span><br><span>@@ -973,6 +973,7 @@</span><br><span> </span><br><span> static int unload_module(void)</span><br><span> {</span><br><span style="color: hsl(120, 100%, 40%);">+#if 0</span><br><span> ast_sip_unregister_event_publisher_handler(&dialog_publisher);</span><br><span> ast_sip_unregister_subscription_handler(&dialog_handler);</span><br><span> ast_sip_unregister_event_publisher_handler(&presence_publisher);</span><br><span>@@ -987,6 +988,18 @@</span><br><span> publishers = NULL;</span><br><span> </span><br><span> return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+#else</span><br><span style="color: hsl(120, 100%, 40%);">+ /* If we were allowed to unload, the above is what we would do.</span><br><span style="color: hsl(120, 100%, 40%);">+ * pjsip_evsub_register_pkg is called by ast_sip_register_subscription_handler</span><br><span style="color: hsl(120, 100%, 40%);">+ * but there is no corresponding unregister function, so unloading</span><br><span style="color: hsl(120, 100%, 40%);">+ * a module does not remove the event package. If this module is ever</span><br><span style="color: hsl(120, 100%, 40%);">+ * loaded again, then pjproject will assert and cause a crash.</span><br><span style="color: hsl(120, 100%, 40%);">+ * For that reason, we must not be allowed to unload, but if</span><br><span style="color: hsl(120, 100%, 40%);">+ * a pjsip_evsub_unregister_pkg API is added in the future</span><br><span style="color: hsl(120, 100%, 40%);">+ * then we should go back to unloading the module as intended.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+ return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span> }</span><br><span> </span><br><span> static int load_module(void)</span><br><span>diff --git a/res/res_pjsip_mwi.c b/res/res_pjsip_mwi.c</span><br><span>index ba68486..dfe5481 100644</span><br><span>--- a/res/res_pjsip_mwi.c</span><br><span>+++ b/res/res_pjsip_mwi.c</span><br><span>@@ -1524,6 +1524,7 @@</span><br><span> </span><br><span> static int unload_module(void)</span><br><span> {</span><br><span style="color: hsl(120, 100%, 40%);">+#if 0</span><br><span> struct ao2_container *unsolicited_mwi;</span><br><span> </span><br><span> ast_sorcery_observer_remove(ast_sip_get_sorcery(), "global", &global_observer);</span><br><span>@@ -1548,6 +1549,18 @@</span><br><span> ast_free(default_voicemail_extension);</span><br><span> default_voicemail_extension = NULL;</span><br><span> return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+#else</span><br><span style="color: hsl(120, 100%, 40%);">+ /* If we were allowed to unload, the above is what we would do.</span><br><span style="color: hsl(120, 100%, 40%);">+ * pjsip_evsub_register_pkg is called by ast_sip_register_subscription_handler</span><br><span style="color: hsl(120, 100%, 40%);">+ * but there is no corresponding unregister function, so unloading</span><br><span style="color: hsl(120, 100%, 40%);">+ * a module does not remove the event package. If this module is ever</span><br><span style="color: hsl(120, 100%, 40%);">+ * loaded again, then pjproject will assert and cause a crash.</span><br><span style="color: hsl(120, 100%, 40%);">+ * For that reason, we must not be allowed to unload, but if</span><br><span style="color: hsl(120, 100%, 40%);">+ * a pjsip_evsub_unregister_pkg API is added in the future</span><br><span style="color: hsl(120, 100%, 40%);">+ * then we should go back to unloading the module as intended.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+ return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span> }</span><br><span> </span><br><span> static int load_module(void)</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/19486">change 19486</a>. To unsubscribe, or for help writing mail filters, 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/c/asterisk/+/19486"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 20 </div>
<div style="display:none"> Gerrit-Change-Id: I7fdcb1a5e44d38b7ba10c44259fe98f0ae9bc12c </div>
<div style="display:none"> Gerrit-Change-Number: 19486 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: N A <asterisk@phreaknet.org> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>