<p>Corey Farrell has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/6833">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip_pubsub: Prevent unload except during shutdown.<br><br>Prevent unload of the module as certain pjsip initialization functions<br>cannot be reversed. This required a reorder of the module_load so that<br>the non-reversable pjsip functions are not called until all potential<br>errors have been ruled out.<br><br>ASTERISK-24483<br><br>Change-Id: Iee900f20bdd6ee1bfe23efdec0d87765eadce8a7<br>---<br>M res/res_pjsip_pubsub.c<br>1 file changed, 16 insertions(+), 15 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/33/6833/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/res/res_pjsip_pubsub.c b/res/res_pjsip_pubsub.c<br>index bcf8677..b54b89d 100644<br>--- a/res/res_pjsip_pubsub.c<br>+++ b/res/res_pjsip_pubsub.c<br>@@ -5355,25 +5355,13 @@<br> <br> sorcery = ast_sip_get_sorcery();<br> <br>- pjsip_evsub_init_module(ast_sip_get_pjsip_endpoint());<br>-<br> if (!(sched = ast_sched_context_create())) {<br> ast_log(LOG_ERROR, "Could not create scheduler for publication expiration\n");<br> return AST_MODULE_LOAD_DECLINE;<br> }<br> <br>- pjsip_media_type_init2(&rlmi_media_type, "application", "rlmi+xml");<br>-<br> if (ast_sched_start_thread(sched)) {<br> ast_log(LOG_ERROR, "Could not start scheduler thread for publication expiration\n");<br>- ast_sched_context_destroy(sched);<br>- return AST_MODULE_LOAD_DECLINE;<br>- }<br>-<br>- pjsip_endpt_add_capability(ast_sip_get_pjsip_endpoint(), NULL, PJSIP_H_ALLOW, NULL, 1, &str_PUBLISH);<br>-<br>- if (ast_sip_register_service(&pubsub_module)) {<br>- ast_log(LOG_ERROR, "Could not register pubsub service\n");<br> ast_sched_context_destroy(sched);<br> return AST_MODULE_LOAD_DECLINE;<br> }<br>@@ -5383,7 +5371,6 @@<br> if (ast_sorcery_object_register(sorcery, "subscription_persistence", subscription_persistence_alloc,<br> NULL, NULL)) {<br> ast_log(LOG_ERROR, "Could not register subscription persistence object support\n");<br>- ast_sip_unregister_service(&pubsub_module);<br> ast_sched_context_destroy(sched);<br> return AST_MODULE_LOAD_DECLINE;<br> }<br>@@ -5411,7 +5398,6 @@<br> CHARFLDSET(struct subscription_persistence, contact_uri));<br> <br> if (apply_list_configuration(sorcery)) {<br>- ast_sip_unregister_service(&pubsub_module);<br> ast_sched_context_destroy(sched);<br> return AST_MODULE_LOAD_DECLINE;<br> }<br>@@ -5420,7 +5406,6 @@<br> if (ast_sorcery_object_register(sorcery, "inbound-publication", publication_resource_alloc,<br> NULL, NULL)) {<br> ast_log(LOG_ERROR, "Could not register subscription persistence object support\n");<br>- ast_sip_unregister_service(&pubsub_module);<br> ast_sched_context_destroy(sched);<br> return AST_MODULE_LOAD_DECLINE;<br> }<br>@@ -5430,6 +5415,22 @@<br> ast_sorcery_object_fields_register(sorcery, "inbound-publication", "^event_", resource_event_handler, NULL);<br> ast_sorcery_reload_object(sorcery, "inbound-publication");<br> <br>+ if (ast_sip_register_service(&pubsub_module)) {<br>+ ast_log(LOG_ERROR, "Could not register pubsub service\n");<br>+ ast_sched_context_destroy(sched);<br>+ return AST_MODULE_LOAD_DECLINE;<br>+ }<br>+<br>+ /* Once we call pjsip_evsub_init_module we cannot unload.<br>+ * Keep all module_load errors above this point. */<br>+ ast_module_shutdown_ref(ast_module_info->self);<br>+<br>+ pjsip_evsub_init_module(ast_sip_get_pjsip_endpoint());<br>+<br>+ pjsip_media_type_init2(&rlmi_media_type, "application", "rlmi+xml");<br>+<br>+ pjsip_endpt_add_capability(ast_sip_get_pjsip_endpoint(), NULL, PJSIP_H_ALLOW, NULL, 1, &str_PUBLISH);<br>+<br> if (ast_test_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED)) {<br> ast_sip_push_task(NULL, subscription_persistence_load, NULL);<br> } else {<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/6833">change 6833</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/6833"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Iee900f20bdd6ee1bfe23efdec0d87765eadce8a7 </div>
<div style="display:none"> Gerrit-Change-Number: 6833 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>