res_pjsip_outbound_publishing: After unloading the library won't load again
[asterisk/asterisk.git] / res / res_pjsip_publish_asterisk.c
index e1b095e..002d976 100644 (file)
@@ -858,9 +858,11 @@ static int load_module(void)
 {
        CHECK_PJSIP_PUBSUB_MODULE_LOADED();
 
+       ast_sorcery_apply_config(ast_sip_get_sorcery(), "asterisk-publication");
        ast_sorcery_apply_default(ast_sip_get_sorcery(), "asterisk-publication", "config", "pjsip.conf,criteria=type=asterisk-publication");
 
        if (ast_sorcery_object_register(ast_sip_get_sorcery(), "asterisk-publication", asterisk_publication_config_alloc, NULL, NULL)) {
+               ast_log(LOG_ERROR, "Unable to register 'asterisk-publication' type with sorcery\n");
                return AST_MODULE_LOAD_DECLINE;
        }
 
@@ -918,12 +920,13 @@ static int unload_module(void)
        ast_sip_unregister_publish_handler(&asterisk_mwi_publication_handler);
        ast_sip_unregister_event_publisher_handler(&asterisk_devicestate_publisher_handler);
        ast_sip_unregister_event_publisher_handler(&asterisk_mwi_publisher_handler);
+       ast_sorcery_object_unregister(ast_sip_get_sorcery(), "asterisk-publication");
        return 0;
 }
 
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PJSIP Asterisk Event PUBLISH Support",
-               .load = load_module,
-               .reload = reload_module,
-               .unload = unload_module,
-               .load_pri = AST_MODPRI_CHANNEL_DEPEND,
+       .load = load_module,
+       .reload = reload_module,
+       .unload = unload_module,
+       .load_pri = AST_MODPRI_CHANNEL_DEPEND + 5,
 );