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

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Remove redundant module checks and references.<br><br>This removes references that are no longer needed due to automatic<br>references created by module dependencies.<br><br>In addition this removes most calls to ast_module_check as they were<br>checking modules which are listed as dependencies.<br><br>Change-Id: I332a6e8383d4c72c8e89d988a184ab8320c4872e<br>---<br>M apps/app_confbridge.c<br>M apps/app_meetme.c<br>M apps/app_stack.c<br>M apps/app_stasis.c<br>M channels/chan_pjsip.c<br>M funcs/func_curl.c<br>M funcs/func_periodic_hook.c<br>M include/asterisk/agi.h<br>M include/asterisk/ari.h<br>M include/asterisk/res_mwi_external.h<br>M include/asterisk/res_pjproject.h<br>M include/asterisk/res_pjsip.h<br>M include/asterisk/res_pjsip_pubsub.h<br>M include/asterisk/res_pjsip_session.h<br>M include/asterisk/stasis_app.h<br>M res/res_agi.c<br>M res/res_ari.c<br>M res/res_ari_applications.c<br>M res/res_ari_asterisk.c<br>M res/res_ari_bridges.c<br>M res/res_ari_channels.c<br>M res/res_ari_device_states.c<br>M res/res_ari_endpoints.c<br>M res/res_ari_events.c<br>M res/res_ari_mailboxes.c<br>M res/res_ari_playbacks.c<br>M res/res_ari_recordings.c<br>M res/res_ari_sounds.c<br>M res/res_config_curl.c<br>M res/res_crypto.c<br>M res/res_curl.c<br>M res/res_fax.c<br>M res/res_hep_pjsip.c<br>M res/res_hep_rtcp.c<br>M res/res_http_media_cache.c<br>M res/res_http_websocket.c<br>M res/res_monitor.c<br>M res/res_mwi_external.c<br>M res/res_mwi_external_ami.c<br>M res/res_pjproject.c<br>M res/res_pjsip.c<br>M res/res_pjsip/config_auth.c<br>M res/res_pjsip/config_transport.c<br>M res/res_pjsip/include/res_pjsip_private.h<br>M res/res_pjsip/location.c<br>M res/res_pjsip/pjsip_distributor.c<br>M res/res_pjsip/pjsip_global_headers.c<br>M res/res_pjsip/pjsip_message_filter.c<br>M res/res_pjsip/pjsip_options.c<br>M res/res_pjsip/pjsip_session.c<br>M res/res_pjsip_acl.c<br>M res/res_pjsip_authenticator_digest.c<br>M res/res_pjsip_caller_id.c<br>M res/res_pjsip_dialog_info_body_generator.c<br>M res/res_pjsip_diversion.c<br>M res/res_pjsip_dlg_options.c<br>M res/res_pjsip_dtmf_info.c<br>M res/res_pjsip_empty_info.c<br>M res/res_pjsip_endpoint_identifier_anonymous.c<br>M res/res_pjsip_endpoint_identifier_ip.c<br>M res/res_pjsip_endpoint_identifier_user.c<br>M res/res_pjsip_exten_state.c<br>M res/res_pjsip_header_funcs.c<br>M res/res_pjsip_history.c<br>M res/res_pjsip_logger.c<br>M res/res_pjsip_messaging.c<br>M res/res_pjsip_mwi.c<br>M res/res_pjsip_mwi_body_generator.c<br>M res/res_pjsip_nat.c<br>M res/res_pjsip_notify.c<br>M res/res_pjsip_one_touch_record_info.c<br>M res/res_pjsip_outbound_authenticator_digest.c<br>M res/res_pjsip_outbound_publish.c<br>M res/res_pjsip_outbound_registration.c<br>M res/res_pjsip_path.c<br>M res/res_pjsip_phoneprov_provider.c<br>M res/res_pjsip_pidf_body_generator.c<br>M res/res_pjsip_pidf_digium_body_supplement.c<br>M res/res_pjsip_pidf_eyebeam_body_supplement.c<br>M res/res_pjsip_publish_asterisk.c<br>M res/res_pjsip_pubsub.c<br>M res/res_pjsip_refer.c<br>M res/res_pjsip_registrar.c<br>M res/res_pjsip_registrar_expire.c<br>M res/res_pjsip_rfc3326.c<br>M res/res_pjsip_sdp_rtp.c<br>M res/res_pjsip_send_to_voicemail.c<br>M res/res_pjsip_session.c<br>M res/res_pjsip_sips_contact.c<br>M res/res_pjsip_t38.c<br>M res/res_pjsip_transport_management.c<br>M res/res_pjsip_transport_websocket.c<br>M res/res_pjsip_xpidf_body_generator.c<br>M res/res_pktccops.c<br>M res/res_smdi.c<br>M res/res_stasis.c<br>M res/res_stasis_mailbox.c<br>M res/res_statsd.c<br>M res/stasis/app.c<br>M rest-api-templates/res_ari_resource.c.mustache<br>M tests/test_res_pjsip_scheduler.c<br>M tests/test_res_stasis.c<br>M tests/test_utils.c<br>103 files changed, 143 insertions(+), 760 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/apps/app_confbridge.c b/apps/app_confbridge.c<br>index f972e38..7e6f94c 100644<br>--- a/apps/app_confbridge.c<br>+++ b/apps/app_confbridge.c<br>@@ -2386,11 +2386,11 @@<br>                user.tech_args.drop_silence = 1;<br>      }<br> <br>- if (ast_test_flag(&user.u_profile, USER_OPT_JITTERBUFFER) && ast_module_check("func_jitterbuffer.so")) {<br>+       if (ast_test_flag(&user.u_profile, USER_OPT_JITTERBUFFER)) {<br>              ast_func_write(chan, "JITTERBUFFER(adaptive)", "default");<br>        }<br> <br>- if (ast_test_flag(&user.u_profile, USER_OPT_DENOISE) && ast_module_check("codec_speex.so")) {<br>+  if (ast_test_flag(&user.u_profile, USER_OPT_DENOISE)) {<br>           ast_func_write(chan, "DENOISE(rx)", "on");<br>        }<br> <br>@@ -4088,4 +4088,5 @@<br>   .unload = unload_module,<br>      .reload = reload,<br>     .load_pri = AST_MODPRI_DEVSTATE_PROVIDER,<br>+    .optional_modules = "codec_speex,func_jitterbuffer",<br> );<br>diff --git a/apps/app_meetme.c b/apps/app_meetme.c<br>index 634eac8..657aaa7 100644<br>--- a/apps/app_meetme.c<br>+++ b/apps/app_meetme.c<br>@@ -3588,7 +3588,7 @@<br>       }<br> <br>  /* Reduce background noise from each participant */<br>-  if (!ast_test_flag64(confflags, CONFFLAG_DONT_DENOISE) && ast_module_check("func_speex.so")) {<br>+     if (!ast_test_flag64(confflags, CONFFLAG_DONT_DENOISE)) {<br>             ast_func_write(chan, "DENOISE(rx)", "on");<br>        }<br> <br>@@ -8085,4 +8085,5 @@<br>   .unload = unload_module,<br>      .reload = reload,<br>     .load_pri = AST_MODPRI_DEVSTATE_PROVIDER,<br>+    .optional_modules = "func_speex",<br> );<br>diff --git a/apps/app_stack.c b/apps/app_stack.c<br>index 1f98378..4560865 100644<br>--- a/apps/app_stack.c<br>+++ b/apps/app_stack.c<br>@@ -1278,7 +1278,7 @@<br> {<br>  ast_install_stack_functions(NULL);<br> <br>-        ast_agi_unregister(ast_module_info->self, &gosub_agi_command);<br>+        ast_agi_unregister(&gosub_agi_command);<br> <br>        ast_unregister_application(app_return);<br>       ast_unregister_application(app_pop);<br>diff --git a/apps/app_stasis.c b/apps/app_stasis.c<br>index 8d09349..b98c2b4 100644<br>--- a/apps/app_stasis.c<br>+++ b/apps/app_stasis.c<br>@@ -125,19 +125,12 @@<br> <br> static int load_module(void)<br> {<br>-       int r = 0;<br>-<br>-        stasis_app_ref();<br>-    r |= ast_register_application_xml(stasis, app_exec);<br>- return r;<br>+    return ast_register_application_xml(stasis, app_exec);<br> }<br> <br> static int unload_module(void)<br> {<br>-   int r = 0;<br>-   r |= ast_unregister_application(stasis);<br>-     stasis_app_unref();<br>-  return r;<br>+    return ast_unregister_application(stasis);<br> }<br> <br> AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Stasis dialplan application",<br>diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c<br>index 68da4a1..2c111fe 100644<br>--- a/channels/chan_pjsip.c<br>+++ b/channels/chan_pjsip.c<br>@@ -2981,8 +2981,6 @@<br> {<br>   struct ao2_container *endpoints;<br> <br>-  CHECK_PJSIP_SESSION_MODULE_LOADED();<br>-<br>       if (!(chan_pjsip_tech.capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {<br>            return AST_MODULE_LOAD_DECLINE;<br>       }<br>@@ -3016,10 +3014,7 @@<br>             goto end;<br>     }<br> <br>- if (ast_sip_session_register_supplement(&chan_pjsip_supplement)) {<br>-               ast_log(LOG_ERROR, "Unable to register PJSIP supplement\n");<br>-               goto end;<br>-    }<br>+    ast_sip_session_register_supplement(&chan_pjsip_supplement);<br> <br>   if (!(pjsip_uids_onhold = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_RWLOCK,<br>                         AO2_CONTAINER_ALLOC_OPT_DUPS_REJECT, 37, uid_hold_hash_fn,<br>@@ -3028,26 +3023,9 @@<br>            goto end;<br>     }<br> <br>- if (ast_sip_session_register_supplement(&call_pickup_supplement)) {<br>-              ast_log(LOG_ERROR, "Unable to register PJSIP call pickup supplement\n");<br>-           ast_sip_session_unregister_supplement(&chan_pjsip_supplement);<br>-           goto end;<br>-    }<br>-<br>- if (ast_sip_session_register_supplement(&pbx_start_supplement)) {<br>-                ast_log(LOG_ERROR, "Unable to register PJSIP pbx start supplement\n");<br>-             ast_sip_session_unregister_supplement(&chan_pjsip_supplement);<br>-           ast_sip_session_unregister_supplement(&call_pickup_supplement);<br>-          goto end;<br>-    }<br>-<br>- if (ast_sip_session_register_supplement(&chan_pjsip_ack_supplement)) {<br>-           ast_log(LOG_ERROR, "Unable to register PJSIP ACK supplement\n");<br>-           ast_sip_session_unregister_supplement(&pbx_start_supplement);<br>-            ast_sip_session_unregister_supplement(&chan_pjsip_supplement);<br>-           ast_sip_session_unregister_supplement(&call_pickup_supplement);<br>-          goto end;<br>-    }<br>+    ast_sip_session_register_supplement(&call_pickup_supplement);<br>+    ast_sip_session_register_supplement(&pbx_start_supplement);<br>+      ast_sip_session_register_supplement(&chan_pjsip_ack_supplement);<br> <br>       if (pjsip_channel_cli_register()) {<br>           ast_log(LOG_ERROR, "Unable to register PJSIP Channel CLI\n");<br>diff --git a/funcs/func_curl.c b/funcs/func_curl.c<br>index ebb3dce..682ad5a 100644<br>--- a/funcs/func_curl.c<br>+++ b/funcs/func_curl.c<br>@@ -920,13 +920,6 @@<br> {<br>        int res;<br> <br>-  if (!ast_module_check("res_curl.so")) {<br>-            if (ast_load_resource("res_curl.so") != AST_MODULE_LOAD_SUCCESS) {<br>-                 ast_log(LOG_ERROR, "Cannot load res_curl, so func_curl cannot be loaded\n");<br>-                       return AST_MODULE_LOAD_DECLINE;<br>-              }<br>-    }<br>-<br>  res = ast_custom_function_register_escalating(&acf_curl, AST_CFE_WRITE);<br>  res |= ast_custom_function_register(&acf_curlopt);<br> <br>@@ -940,4 +933,5 @@<br>        .load = load_module,<br>  .unload = unload_module,<br>      .load_pri = AST_MODPRI_REALTIME_DEPEND2,<br>+     .requires = "res_curl",<br> );<br>diff --git a/funcs/func_periodic_hook.c b/funcs/func_periodic_hook.c<br>index 958da97..1f66747 100644<br>--- a/funcs/func_periodic_hook.c<br>+++ b/funcs/func_periodic_hook.c<br>@@ -486,11 +486,6 @@<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/include/asterisk/agi.h b/include/asterisk/agi.h<br>index cb80f95..568cd5d 100644<br>--- a/include/asterisk/agi.h<br>+++ b/include/asterisk/agi.h<br>@@ -82,13 +82,12 @@<br>  *<br>  * Unregisters an AGI command.<br>  *<br>- * \param mod Pointer to the module_info structure for the module that is unregistering the command<br>  * \param cmd Pointer to the descriptor for the command<br>  * \return 1 on success, 0 if the command was not already registered<br>  *<br>  */<br> AST_OPTIONAL_API(int, ast_agi_unregister,<br>-                 (struct ast_module *mod, agi_command *cmd),<br>+          (agi_command *cmd),<br>           { return AST_OPTIONAL_API_UNAVAILABLE; });<br> <br> /*!<br>@@ -116,7 +115,6 @@<br>  * Unregisters a group of AGI commands, provided as an array of struct agi_command<br>  * entries.<br>  *<br>- * \param mod Pointer to the module_info structure for the module that is unregistering the commands<br>  * \param cmd Pointer to the first entry in the array of command descriptors<br>  * \param len Length of the array (use the ARRAY_LEN macro to determine this easily)<br>  * \return 0 on success, -1 on failure, AST_OPTIONAL_API_UNAVAILABLE if res_agi is not loaded<br>@@ -125,7 +123,7 @@<br>  * remaining commands in the array; it will not reregister the already-unregistered commands.<br>  */<br> AST_OPTIONAL_API(int, ast_agi_unregister_multiple,<br>-                (struct ast_module *mod, struct agi_command *cmd, unsigned int len),<br>+                 (struct agi_command *cmd, unsigned int len),<br>                  { return AST_OPTIONAL_API_UNAVAILABLE; });<br> <br> /*!<br>diff --git a/include/asterisk/ari.h b/include/asterisk/ari.h<br>index f83d596..865b4b0 100644<br>--- a/include/asterisk/ari.h<br>+++ b/include/asterisk/ari.h<br>@@ -268,14 +268,4 @@<br>  */<br> void ast_ari_response_alloc_failed(struct ast_ari_response *response);<br> <br>-/*! \brief Determines whether the res_ari module is loaded */<br>-#define CHECK_ARI_MODULE_LOADED()                               \<br>-    do {                                                    \<br>-            if (!ast_module_check("res_ari.so")           \<br>-                    || !ast_ari_oom_json()) {       \<br>-                    return AST_MODULE_LOAD_DECLINE;         \<br>-            }                                               \<br>-    } while(0)<br>-<br>-<br> #endif /* _ASTERISK_ARI_H */<br>diff --git a/include/asterisk/res_mwi_external.h b/include/asterisk/res_mwi_external.h<br>index 7698a1b..25de700 100644<br>--- a/include/asterisk/res_mwi_external.h<br>+++ b/include/asterisk/res_mwi_external.h<br>@@ -36,22 +36,6 @@<br> <br> /* ------------------------------------------------------------------- */<br> <br>-/*!<br>- * \brief Increase the external MWI resource module reference count.<br>- * \since 12.1.0<br>- *<br>- * \return Nothing<br>- */<br>-void ast_mwi_external_ref(void);<br>-<br>-/*!<br>- * \brief Decrease the external MWI resource module reference count.<br>- * \since 12.1.0<br>- *<br>- * \return Nothing<br>- */<br>-void ast_mwi_external_unref(void);<br>-<br> struct ast_mwi_mailbox_object;<br> <br> /*! \brief Convienience unref function for mailbox object. */<br>diff --git a/include/asterisk/res_pjproject.h b/include/asterisk/res_pjproject.h<br>index 8828b34..4993be6 100644<br>--- a/include/asterisk/res_pjproject.h<br>+++ b/include/asterisk/res_pjproject.h<br>@@ -19,14 +19,6 @@<br> #ifndef _RES_PJPROJECT_H<br> #define _RES_PJPROJECT_H<br> <br>-/*! \brief Determines whether the res_pjproject module is loaded */<br>-#define CHECK_PJPROJECT_MODULE_LOADED()                 \<br>- do {                                                \<br>-                if (!ast_module_check("res_pjproject.so")) {    \<br>-                  return AST_MODULE_LOAD_DECLINE;             \<br>-                }                                               \<br>-    } while(0)<br>-<br> /*!<br>  * \brief Retrieve a pjproject build option<br>  *<br>@@ -78,19 +70,5 @@<br>  * \return Nothing<br>  */<br> void ast_pjproject_log_intercept_end(void);<br>-<br>-/*!<br>- * \brief Increment the res_pjproject reference count.<br>- *<br>- * This ensures graceful shutdown happens in the proper order.<br>- */<br>-void ast_pjproject_ref(void);<br>-<br>-/*!<br>- * \brief Decrement the res_pjproject reference count.<br>- *<br>- * This ensures graceful shutdown happens in the proper order.<br>- */<br>-void ast_pjproject_unref(void);<br> <br> #endif /* _RES_PJPROJECT_H */<br>diff --git a/include/asterisk/res_pjsip.h b/include/asterisk/res_pjsip.h<br>index 66b99b8..a3bd782 100644<br>--- a/include/asterisk/res_pjsip.h<br>+++ b/include/asterisk/res_pjsip.h<br>@@ -933,9 +933,7 @@<br>  * \retval 0 Success<br>  * \retval -1 Failure<br>  */<br>-#define ast_sip_register_service(module) \<br>- __ast_sip_register_service(module, __FILE__, __LINE__, __PRETTY_FUNCTION__)<br>-int __ast_sip_register_service(pjsip_module *module, const char *file, int line, const char *func);<br>+int ast_sip_register_service(pjsip_module *module);<br> <br> /*!<br>  * This is the opposite of ast_sip_register_service().  Unregistering a<br>@@ -944,9 +942,7 @@<br>  *<br>  * \param module The PJSIP module to unregister<br>  */<br>-#define ast_sip_unregister_service(module) \<br>-  __ast_sip_unregister_service(module, __FILE__, __LINE__, __PRETTY_FUNCTION__)<br>-void __ast_sip_unregister_service(pjsip_module *module, const char *file, int line, const char *func);<br>+void ast_sip_unregister_service(pjsip_module *module);<br> <br> /*!<br>  * \brief Register a SIP authenticator<br>@@ -2448,10 +2444,8 @@<br>  * \brief Register an endpoint formatter.<br>  *<br>  * \param obj the formatter to register<br>- * \retval 0 Success<br>- * \retval -1 Failure<br>  */<br>-int ast_sip_register_endpoint_formatter(struct ast_sip_endpoint_formatter *obj);<br>+void ast_sip_register_endpoint_formatter(struct ast_sip_endpoint_formatter *obj);<br> <br> /*!<br>  * \brief Unregister an endpoint formatter.<br>@@ -2627,20 +2621,14 @@<br>  * \retval 0 Success<br>  * \retval -1 Failure<br>  */<br>-#define ast_sip_register_supplement(supplement) \<br>-    __ast_sip_register_supplement(supplement, __FILE__, __LINE__, __PRETTY_FUNCTION__)<br>-int __ast_sip_register_supplement(struct ast_sip_supplement *supplement,<br>-        const char *file, int line, const char *func);<br>+void ast_sip_register_supplement(struct ast_sip_supplement *supplement);<br> <br> /*!<br>  * \brief Unregister a an supplement to SIP out of dialog processing<br>  *<br>  * \param supplement The supplement to unregister<br>  */<br>-#define ast_sip_unregister_supplement(supplement) \<br>-       __ast_sip_unregister_supplement(supplement, __FILE__, __LINE__, __PRETTY_FUNCTION__)<br>-void __ast_sip_unregister_supplement(struct ast_sip_supplement *supplement,<br>-   const char *file, int line, const char *func);<br>+void ast_sip_unregister_supplement(struct ast_sip_supplement *supplement);<br> <br> /*!<br>  * \brief Retrieve the global MWI taskprocessor high water alert trigger level.<br>@@ -2763,15 +2751,6 @@<br>  * \return nothing<br>  */<br> void ast_sip_get_default_from_user(char *from_user, size_t size);<br>-<br>-/*! \brief Determines whether the res_pjsip module is loaded */<br>-#define CHECK_PJSIP_MODULE_LOADED()                                \<br>-    do {                                                    \<br>-            if (!ast_module_check("res_pjsip.so")         \<br>-                    || !ast_sip_get_pjsip_endpoint()) {     \<br>-                    return AST_MODULE_LOAD_DECLINE;         \<br>-            }                                               \<br>-    } while(0)<br> <br> /*!<br>  * \brief Retrieve the system keep alive interval setting.<br>diff --git a/include/asterisk/res_pjsip_pubsub.h b/include/asterisk/res_pjsip_pubsub.h<br>index cb51db3..e9d59a0 100644<br>--- a/include/asterisk/res_pjsip_pubsub.h<br>+++ b/include/asterisk/res_pjsip_pubsub.h<br>@@ -754,13 +754,4 @@<br>  */<br> void ast_sip_subscription_destroy(struct ast_sip_subscription *sub);<br> <br>-/*! \brief Determines whether the res_pjsip_pubsub module is loaded */<br>-#define CHECK_PJSIP_PUBSUB_MODULE_LOADED()                       \<br>-    do {                                                    \<br>-            CHECK_PJSIP_MODULE_LOADED();                    \<br>-            if (!ast_module_check("res_pjsip_pubsub.so")) {       \<br>-                    return AST_MODULE_LOAD_DECLINE;         \<br>-            }                                               \<br>-    } while(0)<br>-<br> #endif /* RES_PJSIP_PUBSUB_H */<br>diff --git a/include/asterisk/res_pjsip_session.h b/include/asterisk/res_pjsip_session.h<br>index 65d4638..f6ee0f0 100644<br>--- a/include/asterisk/res_pjsip_session.h<br>+++ b/include/asterisk/res_pjsip_session.h<br>@@ -579,23 +579,15 @@<br>  * a module could reject an incoming request if desired.<br>  *<br>  * \param supplement The supplement to register<br>- * \retval 0 Success<br>- * \retval -1 Failure<br>  */<br>-#define ast_sip_session_register_supplement(supplement) \<br>-   __ast_sip_session_register_supplement(supplement, __FILE__, __LINE__, __PRETTY_FUNCTION__)<br>-int __ast_sip_session_register_supplement(struct ast_sip_session_supplement *supplement,<br>-        const char *file, int line, const char *func);<br>+void ast_sip_session_register_supplement(struct ast_sip_session_supplement *supplement);<br> <br> /*!<br>  * \brief Unregister a an supplement to SIP session processing<br>  *<br>  * \param supplement The supplement to unregister<br>  */<br>-#define ast_sip_session_unregister_supplement(supplement) \<br>-     __ast_sip_session_unregister_supplement(supplement, __FILE__, __LINE__, __PRETTY_FUNCTION__)<br>-void __ast_sip_session_unregister_supplement(struct ast_sip_session_supplement *supplement,<br>-   const char *file, int line, const char *func);<br>+void ast_sip_session_unregister_supplement(struct ast_sip_session_supplement *supplement);<br> <br> /*!<br>  * \brief Add supplements to a SIP session<br>@@ -893,14 +885,5 @@<br>  * \note This function is guaranteed to return non-NULL<br>  */<br> struct ast_sip_session_media *ast_sip_session_media_get_transport(struct ast_sip_session *session, struct ast_sip_session_media *session_media);<br>-<br>-/*! \brief Determines whether the res_pjsip_session module is loaded */<br>-#define CHECK_PJSIP_SESSION_MODULE_LOADED()                           \<br>-    do {                                                            \<br>-            CHECK_PJSIP_MODULE_LOADED();                            \<br>-            if (!ast_module_check("res_pjsip_session.so")) {      \<br>-                    return AST_MODULE_LOAD_DECLINE;                 \<br>-            }                                                       \<br>-    } while(0)<br> <br> #endif /* _RES_PJSIP_SESSION_H */<br>diff --git a/include/asterisk/stasis_app.h b/include/asterisk/stasis_app.h<br>index 8ef2bda..b0829ab 100644<br>--- a/include/asterisk/stasis_app.h<br>+++ b/include/asterisk/stasis_app.h<br>@@ -46,8 +46,8 @@<br>  * functions.<br>  *<br>  * Since module unload order is based on reference counting, any module that<br>- * uses the API defined in this file must call stasis_app_ref() when loaded,<br>- * and stasis_app_unref() when unloaded.<br>+ * uses the API defined in this file must list "res_stasis" in the requires<br>+ * field.<br>  */<br> <br> #include "asterisk/channel.h"<br>@@ -227,18 +227,6 @@<br>  * \brief Register core event sources.<br>  */<br> void stasis_app_register_event_sources(void);<br>-<br>-/*!<br>- * \brief Checks to see if the given object is a core event source<br>- *<br>- * \note core event sources are currently only endpoint, bridge, and channel.<br>- *<br>- * \param obj event source object to check<br>- *<br>- * \return non-zero if core event source, otherwise 0 (false)<br>-<br>- */<br>-int stasis_app_is_core_event_source(struct stasis_app_event_source *obj);<br> <br> /*!<br>  * \brief Unregister an application event source.<br>@@ -848,20 +836,6 @@<br>  * \retval zero on success<br>  */<br> void stasis_app_bridge_destroy(const char *bridge_id);<br>-<br>-/*!<br>- * \brief Increment the res_stasis reference count.<br>- *<br>- * This ensures graceful shutdown happens in the proper order.<br>- */<br>-void stasis_app_ref(void);<br>-<br>-/*!<br>- * \brief Decrement the res_stasis reference count.<br>- *<br>- * This ensures graceful shutdown happens in the proper order.<br>- */<br>-void stasis_app_unref(void);<br> <br> /*!<br>  * \brief Get the Stasis message sanitizer for app_stasis applications<br>diff --git a/res/res_agi.c b/res/res_agi.c<br>index 2d0dc27..0931c1a 100644<br>--- a/res/res_agi.c<br>+++ b/res/res_agi.c<br>@@ -3815,8 +3815,6 @@<br>             AST_RWLIST_WRLOCK(&agi_commands);<br>                 AST_LIST_INSERT_TAIL(&agi_commands, cmd, list);<br>           AST_RWLIST_UNLOCK(&agi_commands);<br>-                if (mod != ast_module_info->self)<br>-                 ast_module_ref(ast_module_info->self);<br>             ast_verb(2, "AGI Command '%s' registered\n",fullcmd);<br>               return 1;<br>     } else {<br>@@ -3825,7 +3823,7 @@<br>       }<br> }<br> <br>-int AST_OPTIONAL_API_NAME(ast_agi_unregister)(struct ast_module *mod, agi_command *cmd)<br>+int AST_OPTIONAL_API_NAME(ast_agi_unregister)(agi_command *cmd)<br> {<br>      struct agi_command *e;<br>        int unregistered = 0;<br>@@ -3837,8 +3835,6 @@<br>  AST_RWLIST_TRAVERSE_SAFE_BEGIN(&agi_commands, e, list) {<br>          if (cmd == e) {<br>                       AST_RWLIST_REMOVE_CURRENT(list);<br>-                     if (mod != ast_module_info->self)<br>-                         ast_module_unref(ast_module_info->self);<br> #ifdef AST_XML_DOCS<br>                     if (e->docsrc == AST_XML_DOC) {<br>                            ast_free((char *) e->summary);<br>@@ -3885,7 +3881,7 @@<br>                         to fail is if the command is not<br>                      registered<br>                         */<br>-                   (void) ast_agi_unregister(mod, cmd + x - 1);<br>+                 (void) ast_agi_unregister(cmd + x - 1);<br>               }<br>             return -1;<br>    }<br>@@ -3893,7 +3889,7 @@<br>      return 0;<br> }<br> <br>-int AST_OPTIONAL_API_NAME(ast_agi_unregister_multiple)(struct ast_module *mod, struct agi_command *cmd, unsigned int len)<br>+int AST_OPTIONAL_API_NAME(ast_agi_unregister_multiple)(struct agi_command *cmd, unsigned int len)<br> {<br>  unsigned int i;<br>       int res = 0;<br>@@ -3903,7 +3899,7 @@<br>              attempts failed... there is no recourse if<br>                    any of them do<br>             */<br>-           res |= ast_agi_unregister(mod, cmd + i);<br>+             res |= ast_agi_unregister(cmd + i);<br>   }<br> <br>  return res;<br>@@ -4659,7 +4655,7 @@<br>    }<br> #endif<br> <br>-        ast_agi_unregister(ast_module_info->self, &noop_command);<br>+     ast_agi_unregister(&noop_command);<br>        return res;<br> }<br> #endif<br>@@ -4673,7 +4669,7 @@<br>       STASIS_MESSAGE_TYPE_CLEANUP(agi_async_end_type);<br> <br>   ast_cli_unregister_multiple(cli_agi, ARRAY_LEN(cli_agi));<br>-    ast_agi_unregister_multiple(ast_module_info->self, commands, ARRAY_LEN(commands));<br>+        ast_agi_unregister_multiple(commands, ARRAY_LEN(commands));<br>   ast_unregister_application(eapp);<br>     ast_unregister_application(deadapp);<br>  ast_manager_unregister("AGI");<br>@@ -4705,9 +4701,6 @@<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>diff --git a/res/res_ari.c b/res/res_ari.c<br>index 6ce25a5..5ffb583 100644<br>--- a/res/res_ari.c<br>+++ b/res/res_ari.c<br>@@ -196,7 +196,6 @@<br>         ao2_cleanup(root_handler);<br>    ao2_ref(new_handler, +1);<br>     root_handler = new_handler;<br>-  ast_module_ref(ast_module_info->self);<br>     return 0;<br> }<br> <br>@@ -222,7 +221,6 @@<br>         memcpy(new_handler, root_handler, sizeof(*new_handler));<br>      for (i = 0, j = 0; i < root_handler->num_children; ++i) {<br>               if (root_handler->children[i] == handler) {<br>-                       ast_module_unref(ast_module_info->self);<br>                   continue;<br>             }<br>             new_handler->children[j++] = root_handler->children[i];<br>diff --git a/res/res_ari_applications.c b/res/res_ari_applications.c<br>index 323bdb3..fd8a448 100644<br>--- a/res/res_ari_applications.c<br>+++ b/res/res_ari_applications.c<br>@@ -493,7 +493,6 @@<br> static int unload_module(void)<br> {<br>      ast_ari_remove_handler(&applications);<br>-   stasis_app_unref();<br>   return 0;<br> }<br> <br>@@ -501,10 +500,7 @@<br> {<br>    int res = 0;<br> <br>-      CHECK_ARI_MODULE_LOADED();<br> <br>-<br>-     stasis_app_ref();<br>     res |= ast_ari_add_handler(&applications);<br>        if (res) {<br>            unload_module();<br>diff --git a/res/res_ari_asterisk.c b/res/res_ari_asterisk.c<br>index 9f76f93..e143a7f 100644<br>--- a/res/res_ari_asterisk.c<br>+++ b/res/res_ari_asterisk.c<br>@@ -1214,7 +1214,6 @@<br> static int unload_module(void)<br> {<br>         ast_ari_remove_handler(&asterisk);<br>-       stasis_app_unref();<br>   return 0;<br> }<br> <br>@@ -1222,10 +1221,7 @@<br> {<br>  int res = 0;<br> <br>-      CHECK_ARI_MODULE_LOADED();<br> <br>-<br>-     stasis_app_ref();<br>     res |= ast_ari_add_handler(&asterisk);<br>    if (res) {<br>            unload_module();<br>diff --git a/res/res_ari_bridges.c b/res/res_ari_bridges.c<br>index 34b9d89..3649d29 100644<br>--- a/res/res_ari_bridges.c<br>+++ b/res/res_ari_bridges.c<br>@@ -1554,7 +1554,6 @@<br> static int unload_module(void)<br> {<br>     ast_ari_remove_handler(&bridges);<br>-        stasis_app_unref();<br>   return 0;<br> }<br> <br>@@ -1562,10 +1561,7 @@<br> {<br>  int res = 0;<br> <br>-      CHECK_ARI_MODULE_LOADED();<br> <br>-<br>-     stasis_app_ref();<br>     res |= ast_ari_add_handler(&bridges);<br>     if (res) {<br>            unload_module();<br>diff --git a/res/res_ari_channels.c b/res/res_ari_channels.c<br>index 7862c10..ab9ec63 100644<br>--- a/res/res_ari_channels.c<br>+++ b/res/res_ari_channels.c<br>@@ -2844,7 +2844,6 @@<br> static int unload_module(void)<br> {<br>         ast_ari_remove_handler(&channels);<br>-       stasis_app_unref();<br>   return 0;<br> }<br> <br>@@ -2852,10 +2851,7 @@<br> {<br>  int res = 0;<br> <br>-      CHECK_ARI_MODULE_LOADED();<br> <br>-<br>-     stasis_app_ref();<br>     res |= ast_ari_add_handler(&channels);<br>    if (res) {<br>            unload_module();<br>diff --git a/res/res_ari_device_states.c b/res/res_ari_device_states.c<br>index ec8890b..fe3f092 100644<br>--- a/res/res_ari_device_states.c<br>+++ b/res/res_ari_device_states.c<br>@@ -324,7 +324,6 @@<br> static int unload_module(void)<br> {<br>       ast_ari_remove_handler(&deviceStates);<br>-   stasis_app_unref();<br>   return 0;<br> }<br> <br>@@ -332,10 +331,7 @@<br> {<br>    int res = 0;<br> <br>-      CHECK_ARI_MODULE_LOADED();<br> <br>-<br>-     stasis_app_ref();<br>     res |= ast_ari_add_handler(&deviceStates);<br>        if (res) {<br>            unload_module();<br>diff --git a/res/res_ari_endpoints.c b/res/res_ari_endpoints.c<br>index 07197ca..947da71 100644<br>--- a/res/res_ari_endpoints.c<br>+++ b/res/res_ari_endpoints.c<br>@@ -448,7 +448,6 @@<br> static int unload_module(void)<br> {<br>       ast_ari_remove_handler(&endpoints);<br>-      stasis_app_unref();<br>   return 0;<br> }<br> <br>@@ -456,10 +455,7 @@<br> {<br>    int res = 0;<br> <br>-      CHECK_ARI_MODULE_LOADED();<br> <br>-<br>-     stasis_app_ref();<br>     res |= ast_ari_add_handler(&endpoints);<br>   if (res) {<br>            unload_module();<br>diff --git a/res/res_ari_events.c b/res/res_ari_events.c<br>index f750a54..1a14ce8 100644<br>--- a/res/res_ari_events.c<br>+++ b/res/res_ari_events.c<br>@@ -423,7 +423,6 @@<br>        ao2_cleanup(events.ws_server);<br>        events.ws_server = NULL;<br>      ast_ari_websocket_events_event_websocket_dtor();<br>-     stasis_app_unref();<br>   return 0;<br> }<br> <br>@@ -431,35 +430,29 @@<br> {<br>   int res = 0;<br> <br>-      CHECK_ARI_MODULE_LOADED();<br>+   struct ast_websocket_protocol *protocol;<br> <br>-  /* This is scoped to not conflict with CHECK_ARI_MODULE_LOADED */<br>-    {<br>-            struct ast_websocket_protocol *protocol;<br>-<br>-          if (ast_ari_websocket_events_event_websocket_init() == -1) {<br>-                 return AST_MODULE_LOAD_DECLINE;<br>-              }<br>-<br>-         events.ws_server = ast_websocket_server_create();<br>-            if (!events.ws_server) {<br>-                     ast_ari_websocket_events_event_websocket_dtor();<br>-                     return AST_MODULE_LOAD_DECLINE;<br>-              }<br>-<br>-         protocol = ast_websocket_sub_protocol_alloc("ari");<br>-                if (!protocol) {<br>-                     ao2_ref(events.ws_server, -1);<br>-                       events.ws_server = NULL;<br>-                     ast_ari_websocket_events_event_websocket_dtor();<br>-                     return AST_MODULE_LOAD_DECLINE;<br>-              }<br>-            protocol->session_attempted = ast_ari_events_event_websocket_ws_attempted_cb;<br>-             protocol->session_established = ast_ari_events_event_websocket_ws_established_cb;<br>-         res |= ast_websocket_server_add_protocol2(events.ws_server, protocol);<br>+       if (ast_ari_websocket_events_event_websocket_init() == -1) {<br>+         return AST_MODULE_LOAD_DECLINE;<br>       }<br> <br>- stasis_app_ref();<br>+    events.ws_server = ast_websocket_server_create();<br>+    if (!events.ws_server) {<br>+             ast_ari_websocket_events_event_websocket_dtor();<br>+             return AST_MODULE_LOAD_DECLINE;<br>+      }<br>+<br>+ protocol = ast_websocket_sub_protocol_alloc("ari");<br>+        if (!protocol) {<br>+             ao2_ref(events.ws_server, -1);<br>+               events.ws_server = NULL;<br>+             ast_ari_websocket_events_event_websocket_dtor();<br>+             return AST_MODULE_LOAD_DECLINE;<br>+      }<br>+    protocol->session_attempted = ast_ari_events_event_websocket_ws_attempted_cb;<br>+     protocol->session_established = ast_ari_events_event_websocket_ws_established_cb;<br>+ res |= ast_websocket_server_add_protocol2(events.ws_server, protocol);<br>+<br>     res |= ast_ari_add_handler(&events);<br>      if (res) {<br>            unload_module();<br>diff --git a/res/res_ari_mailboxes.c b/res/res_ari_mailboxes.c<br>index 6469f93..9761836 100644<br>--- a/res/res_ari_mailboxes.c<br>+++ b/res/res_ari_mailboxes.c<br>@@ -330,7 +330,6 @@<br> static int unload_module(void)<br> {<br>       ast_ari_remove_handler(&mailboxes);<br>-      stasis_app_unref();<br>   return 0;<br> }<br> <br>@@ -338,10 +337,7 @@<br> {<br>    int res = 0;<br> <br>-      CHECK_ARI_MODULE_LOADED();<br> <br>-<br>-     stasis_app_ref();<br>     res |= ast_ari_add_handler(&mailboxes);<br>   if (res) {<br>            unload_module();<br>diff --git a/res/res_ari_playbacks.c b/res/res_ari_playbacks.c<br>index 0148a74..9611717 100644<br>--- a/res/res_ari_playbacks.c<br>+++ b/res/res_ari_playbacks.c<br>@@ -282,7 +282,6 @@<br> static int unload_module(void)<br> {<br>       ast_ari_remove_handler(&playbacks);<br>-      stasis_app_unref();<br>   return 0;<br> }<br> <br>@@ -290,10 +289,7 @@<br> {<br>    int res = 0;<br> <br>-      CHECK_ARI_MODULE_LOADED();<br> <br>-<br>-     stasis_app_ref();<br>     res |= ast_ari_add_handler(&playbacks);<br>   if (res) {<br>            unload_module();<br>diff --git a/res/res_ari_recordings.c b/res/res_ari_recordings.c<br>index 531ff65..39864bc 100644<br>--- a/res/res_ari_recordings.c<br>+++ b/res/res_ari_recordings.c<br>@@ -866,7 +866,6 @@<br> static int unload_module(void)<br> {<br>   ast_ari_remove_handler(&recordings);<br>-     stasis_app_unref();<br>   return 0;<br> }<br> <br>@@ -874,10 +873,7 @@<br> {<br>    int res = 0;<br> <br>-      CHECK_ARI_MODULE_LOADED();<br> <br>-<br>-     stasis_app_ref();<br>     res |= ast_ari_add_handler(&recordings);<br>  if (res) {<br>            unload_module();<br>diff --git a/res/res_ari_sounds.c b/res/res_ari_sounds.c<br>index 5c27ebd..b9c9bdf 100644<br>--- a/res/res_ari_sounds.c<br>+++ b/res/res_ari_sounds.c<br>@@ -212,7 +212,6 @@<br> static int unload_module(void)<br> {<br>   ast_ari_remove_handler(&sounds);<br>- stasis_app_unref();<br>   return 0;<br> }<br> <br>@@ -220,10 +219,7 @@<br> {<br>    int res = 0;<br> <br>-      CHECK_ARI_MODULE_LOADED();<br> <br>-<br>-     stasis_app_ref();<br>     res |= ast_ari_add_handler(&sounds);<br>      if (res) {<br>            unload_module();<br>diff --git a/res/res_config_curl.c b/res/res_config_curl.c<br>index 2132097..03f0338 100644<br>--- a/res/res_config_curl.c<br>+++ b/res/res_config_curl.c<br>@@ -637,20 +637,6 @@<br> <br> static int load_module(void)<br> {<br>-    if (!ast_module_check("res_curl.so")) {<br>-            if (ast_load_resource("res_curl.so") != AST_MODULE_LOAD_SUCCESS) {<br>-                 ast_log(LOG_ERROR, "Cannot load res_curl, so res_config_curl cannot be loaded\n");<br>-                 return AST_MODULE_LOAD_DECLINE;<br>-              }<br>-    }<br>-<br>- if (!ast_module_check("func_curl.so")) {<br>-           if (ast_load_resource("func_curl.so") != AST_MODULE_LOAD_SUCCESS) {<br>-                        ast_log(LOG_ERROR, "Cannot load func_curl, so res_config_curl cannot be loaded\n");<br>-                        return AST_MODULE_LOAD_DECLINE;<br>-              }<br>-    }<br>-<br>  reload_module();<br> <br>   ast_config_engine_register(&curl_engine);<br>@@ -664,4 +650,5 @@<br>    .unload = unload_module,<br>      .reload = reload_module,<br>      .load_pri = AST_MODPRI_REALTIME_DRIVER,<br>+      .requires = "res_curl,func_curl",<br> );<br>diff --git a/res/res_crypto.c b/res/res_crypto.c<br>index 8f97ce9..4f8f2cb 100644<br>--- a/res/res_crypto.c<br>+++ b/res/res_crypto.c<br>@@ -651,8 +651,6 @@<br>                crypto_load(-1, -1);<br>  }<br> <br>- /* This prevents dlclose from ever running, but allows CLI cleanup at shutdown. */<br>-   ast_module_shutdown_ref(ast_module_info->self);<br>    return AST_MODULE_LOAD_SUCCESS;<br> }<br> <br>@@ -663,7 +661,6 @@<br>   return 0;<br> }<br> <br>-/* needs usecount semantics defined */<br> AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "Cryptographic Digital Signatures",<br>      .support_level = AST_MODULE_SUPPORT_CORE,<br>     .load = load_module,<br>diff --git a/res/res_curl.c b/res/res_curl.c<br>index e0f753c..3dc7c2f 100644<br>--- a/res/res_curl.c<br>+++ b/res/res_curl.c<br>@@ -46,33 +46,11 @@<br> <br> #include "asterisk/module.h"<br> <br>-static const char *dependents[] = {<br>-      "func_curl.so",<br>-    "res_config_curl.so",<br>-      "res_http_media_cache.so",<br>-};<br>-<br> static int unload_module(void)<br> {<br>-    int res = 0;<br>- size_t i;<br>-<br>- /* If the dependent modules are still in memory, forbid unload */<br>-    for (i = 0; i < ARRAY_LEN(dependents); i++) {<br>-             if (ast_module_check(dependents[i])) {<br>-                       if (!ast_shutting_down()) {<br>-                          ast_log(LOG_WARNING, "%s (dependent module) is still loaded.  Cannot unload res_curl.so\n", dependents[i]);<br>-                        }<br>-                    res = -1;<br>-            }<br>-    }<br>-<br>- if (res)<br>-             return -1;<br>-<br>         curl_global_cleanup();<br> <br>-    return res;<br>+  return 0;<br> }<br> <br> static int load_module(void)<br>diff --git a/res/res_fax.c b/res/res_fax.c<br>index 4be5aee..315f000 100644<br>--- a/res/res_fax.c<br>+++ b/res/res_fax.c<br>@@ -978,7 +978,6 @@<br>     AST_RWLIST_WRLOCK(&faxmodules);<br>   AST_RWLIST_INSERT_TAIL(&faxmodules, fax, list);<br>   AST_RWLIST_UNLOCK(&faxmodules);<br>-  ast_module_ref(ast_module_info->self);<br> <br>  ast_verb(3, "Registered handler for '%s' (%s)\n", fax->tech->type, fax->tech->description);<br> <br>@@ -998,7 +997,6 @@<br>                     continue;<br>             }<br>             AST_RWLIST_REMOVE_CURRENT(list);<br>-             ast_module_unref(ast_module_info->self);<br>           ast_free(fax);<br>                ast_verb(4, "Unregistered FAX module type '%s'\n", tech->type);<br>          break;<br>diff --git a/res/res_hep_pjsip.c b/res/res_hep_pjsip.c<br>index ff02675..be2f6ea 100644<br>--- a/res/res_hep_pjsip.c<br>+++ b/res/res_hep_pjsip.c<br>@@ -232,10 +232,8 @@<br> <br> static int load_module(void)<br> {<br>-      CHECK_PJSIP_MODULE_LOADED();<br>-<br>-      if (!ast_module_check("res_hep.so") || !hepv3_is_loaded()) {<br>-               ast_log(AST_LOG_WARNING, "res_hep is not loaded or running; declining module load\n");<br>+     if (!hepv3_is_loaded()) {<br>+            ast_log(AST_LOG_WARNING, "res_hep is disabled; declining module load\n");<br>           return AST_MODULE_LOAD_DECLINE;<br>       }<br> <br>diff --git a/res/res_hep_rtcp.c b/res/res_hep_rtcp.c<br>index 199c816..c3abbc1 100644<br>--- a/res/res_hep_rtcp.c<br>+++ b/res/res_hep_rtcp.c<br>@@ -157,8 +157,8 @@<br> <br> static int load_module(void)<br> {<br>-     if (!ast_module_check("res_hep.so") || !hepv3_is_loaded()) {<br>-               ast_log(AST_LOG_WARNING, "res_hep is not loaded or running; declining module load\n");<br>+     if (!hepv3_is_loaded()) {<br>+            ast_log(AST_LOG_WARNING, "res_hep is disabled; declining module load\n");<br>           return AST_MODULE_LOAD_DECLINE;<br>       }<br> <br>diff --git a/res/res_http_media_cache.c b/res/res_http_media_cache.c<br>index 918686e..eba7ecc 100644<br>--- a/res/res_http_media_cache.c<br>+++ b/res/res_http_media_cache.c<br>@@ -441,4 +441,5 @@<br>            .support_level = AST_MODULE_SUPPORT_CORE,<br>             .load = load_module,<br>          .unload = unload_module,<br>+             .requires = "res_curl",<br>     );<br>diff --git a/res/res_http_websocket.c b/res/res_http_websocket.c<br>index 86a1547..bcad1c3 100644<br>--- a/res/res_http_websocket.c<br>+++ b/res/res_http_websocket.c<br>@@ -131,24 +131,18 @@<br>    struct ao2_container *protocols; /*!< Container for registered protocols */<br> };<br> <br>-static void websocket_server_internal_dtor(void *obj)<br>+static void websocket_server_dtor(void *obj)<br> {<br>     struct ast_websocket_server *server = obj;<br>    ao2_cleanup(server->protocols);<br>    server->protocols = NULL;<br> }<br> <br>-static void websocket_server_dtor(void *obj)<br>-{<br>-       websocket_server_internal_dtor(obj);<br>- ast_module_unref(ast_module_info->self);<br>-}<br>-<br>-static struct ast_websocket_server *websocket_server_create_impl(void (*dtor)(void *))<br>+static struct ast_websocket_server *websocket_server_create_impl(void)<br> {<br>      RAII_VAR(struct ast_websocket_server *, server, NULL, ao2_cleanup);<br> <br>-       server = ao2_alloc(sizeof(*server), dtor);<br>+   server = ao2_alloc(sizeof(*server), websocket_server_dtor);<br>   if (!server) {<br>                return NULL;<br>  }<br>@@ -164,13 +158,12 @@<br> <br> static struct ast_websocket_server *websocket_server_internal_create(void)<br> {<br>- return websocket_server_create_impl(websocket_server_internal_dtor);<br>+ return websocket_server_create_impl();<br> }<br> <br> struct ast_websocket_server *AST_OPTIONAL_API_NAME(ast_websocket_server_create)(void)<br> {<br>-    ast_module_ref(ast_module_info->self);<br>-    return websocket_server_create_impl(websocket_server_dtor);<br>+  return websocket_server_create_impl();<br> }<br> <br> /*! \brief Destructor function for sessions */<br>@@ -997,11 +990,7 @@<br> <br> int AST_OPTIONAL_API_NAME(ast_websocket_add_protocol)(const char *name, ast_websocket_callback callback)<br> {<br>-       int res = websocket_add_protocol_internal(name, callback);<br>-   if (res == 0) {<br>-              ast_module_ref(ast_module_info->self);<br>-    }<br>-    return res;<br>+  return websocket_add_protocol_internal(name, callback);<br> }<br> <br> int AST_OPTIONAL_API_NAME(ast_websocket_add_protocol2)(struct ast_websocket_protocol *protocol)<br>@@ -1016,7 +1005,6 @@<br>               return -1;<br>    }<br> <br>- ast_module_ref(ast_module_info->self);<br>     return 0;<br> }<br> <br>@@ -1031,11 +1019,7 @@<br> <br> int AST_OPTIONAL_API_NAME(ast_websocket_remove_protocol)(const char *name, ast_websocket_callback callback)<br> {<br>-        int res = websocket_remove_protocol_internal(name, callback);<br>-        if (res == 0) {<br>-              ast_module_unref(ast_module_info->self);<br>-  }<br>-    return res;<br>+  return websocket_remove_protocol_internal(name, callback);<br> }<br> <br> /*! \brief Parse the given uri into a path and remote address.<br>@@ -1456,9 +1440,6 @@<br>     }<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>diff --git a/res/res_monitor.c b/res/res_monitor.c<br>index 9dcbdbe..c67b37e 100644<br>--- a/res/res_monitor.c<br>+++ b/res/res_monitor.c<br>@@ -985,9 +985,6 @@<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_mwi_external.c b/res/res_mwi_external.c<br>index d797991..82c74b9 100644<br>--- a/res/res_mwi_external.c<br>+++ b/res/res_mwi_external.c<br>@@ -81,16 +81,6 @@<br> <br> static struct ast_sorcery *mwi_sorcery;<br> <br>-void ast_mwi_external_ref(void)<br>-{<br>-    ast_module_ref(ast_module_info->self);<br>-}<br>-<br>-void ast_mwi_external_unref(void)<br>-{<br>-     ast_module_unref(ast_module_info->self);<br>-}<br>-<br> /*!<br>  * \internal<br>  * \brief Post an update event to the MWI counts.<br>diff --git a/res/res_mwi_external_ami.c b/res/res_mwi_external_ami.c<br>index 8639fad..e4d5054 100644<br>--- a/res/res_mwi_external_ami.c<br>+++ b/res/res_mwi_external_ami.c<br>@@ -342,17 +342,12 @@<br>   ast_manager_unregister("MWIDelete");<br>        ast_manager_unregister("MWIUpdate");<br> <br>-    /* Must be done last */<br>-      ast_mwi_external_unref();<br>     return 0;<br> }<br> <br> static int load_module(void)<br> {<br>   int res;<br>-<br>-  /* Must be done first */<br>-     ast_mwi_external_ref();<br> <br>    res = 0;<br>      res |= ast_manager_register_xml("MWIGet", EVENT_FLAG_CALL | EVENT_FLAG_REPORTING, mwi_mailbox_get);<br>diff --git a/res/res_pjproject.c b/res/res_pjproject.c<br>index 6137898..f506a62 100644<br>--- a/res/res_pjproject.c<br>+++ b/res/res_pjproject.c<br>@@ -280,16 +280,6 @@<br>      ast_mutex_unlock(&pjproject_log_intercept_lock);<br> }<br> <br>-void ast_pjproject_ref(void)<br>-{<br>-       ast_module_ref(ast_module_info->self);<br>-}<br>-<br>-void ast_pjproject_unref(void)<br>-{<br>-        ast_module_unref(ast_module_info->self);<br>-}<br>-<br> static char *handle_pjproject_show_buildopts(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)<br> {<br>       int i;<br>diff --git a/res/res_pjsip.c b/res/res_pjsip.c<br>index 05f92f2..f7154aa 100644<br>--- a/res/res_pjsip.c<br>+++ b/res/res_pjsip.c<br>@@ -2716,7 +2716,7 @@<br> /*! Local host address for IPv6 (string form) */<br> static char host_ip_ipv6_string[PJ_INET6_ADDRSTRLEN];<br> <br>-static int register_service_noref(void *data)<br>+static int register_service(void *data)<br> {<br>        pjsip_module **module = data;<br>         if (!ast_pjsip_endpoint) {<br>@@ -2731,23 +2731,12 @@<br>   return 0;<br> }<br> <br>-int internal_sip_register_service(pjsip_module *module)<br>+int ast_sip_register_service(pjsip_module *module)<br> {<br>-  return ast_sip_push_task_synchronous(NULL, register_service_noref, &module);<br>+     return ast_sip_push_task_synchronous(NULL, register_service, &module);<br> }<br> <br>-int __ast_sip_register_service(pjsip_module *module, const char *file, int line, const char *func)<br>-{<br>-   int res;<br>-<br>-  if (!(res = ast_sip_push_task_synchronous(NULL, register_service_noref, &module))) {<br>-             __ast_module_ref(ast_module_info->self, file, line, func);<br>-        }<br>-<br>- return res;<br>-}<br>-<br>-static int unregister_service_noref(void *data)<br>+static int unregister_service(void *data)<br> {<br>  pjsip_module **module = data;<br>         if (!ast_pjsip_endpoint) {<br>@@ -2758,16 +2747,9 @@<br>    return 0;<br> }<br> <br>-int internal_sip_unregister_service(pjsip_module *module)<br>+void ast_sip_unregister_service(pjsip_module *module)<br> {<br>-     return ast_sip_push_task_synchronous(NULL, unregister_service_noref, &module);<br>-}<br>-<br>-void __ast_sip_unregister_service(pjsip_module *module, const char *file, int line, const char *func)<br>-{<br>-        if (!ast_sip_push_task_synchronous(NULL, unregister_service_noref, &module)) {<br>-           __ast_module_unref(ast_module_info->self, file, line, func);<br>-      }<br>+    ast_sip_push_task_synchronous(NULL, unregister_service, &module);<br> }<br> <br> static struct ast_sip_authenticator *registered_authenticator;<br>@@ -2780,7 +2762,7 @@<br>  }<br>     registered_authenticator = auth;<br>      ast_debug(1, "Registered SIP authenticator module %p\n", auth);<br>-    ast_module_ref(ast_module_info->self);<br>+<br>  return 0;<br> }<br> <br>@@ -2793,7 +2775,6 @@<br>       }<br>     registered_authenticator = NULL;<br>      ast_debug(1, "Unregistered SIP authenticator %p\n", auth);<br>- ast_module_unref(ast_module_info->self);<br> }<br> <br> int ast_sip_requires_authentication(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)<br>@@ -2826,7 +2807,7 @@<br>      }<br>     registered_outbound_authenticator = auth;<br>     ast_debug(1, "Registered SIP outbound authenticator module %p\n", auth);<br>-   ast_module_ref(ast_module_info->self);<br>+<br>  return 0;<br> }<br> <br>@@ -2839,7 +2820,6 @@<br>       }<br>     registered_outbound_authenticator = NULL;<br>     ast_debug(1, "Unregistered SIP outbound authenticator %p\n", auth);<br>-        ast_module_unref(ast_module_info->self);<br> }<br> <br> int ast_sip_create_request_with_auth(const struct ast_sip_auth_vector *auths, pjsip_rx_data *challenge,<br>@@ -2881,7 +2861,6 @@<br>   if (ast_strlen_zero(name)) {<br>          /* if an identifier has no name then place in front */<br>                AST_RWLIST_INSERT_HEAD(&endpoint_identifiers, id_list_item, list);<br>-               ast_module_ref(ast_module_info->self);<br>             return 0;<br>     }<br> <br>@@ -2891,7 +2870,6 @@<br>   if (ast_strlen_zero(identifier_order)) {<br>              id_list_item->priority = UINT_MAX;<br>                 AST_RWLIST_INSERT_TAIL(&endpoint_identifiers, id_list_item, list);<br>-               ast_module_ref(ast_module_info->self);<br>             ast_free(identifier_order);<br>           return 0;<br>     }<br>@@ -2919,7 +2897,6 @@<br>              /* if not in the endpoint_identifier_order list then consider it less in<br>                 priority and add it to the end */<br>          AST_RWLIST_INSERT_TAIL(&endpoint_identifiers, id_list_item, list);<br>-               ast_module_ref(ast_module_info->self);<br>             ast_free(identifier_order);<br>           return 0;<br>     }<br>@@ -2937,7 +2914,6 @@<br>      }<br>     AST_RWLIST_TRAVERSE_SAFE_END;<br> <br>-     ast_module_ref(ast_module_info->self);<br>     ast_free(identifier_order);<br>   return 0;<br> }<br>@@ -2956,7 +2932,6 @@<br>                  AST_RWLIST_REMOVE_CURRENT(list);<br>                      ast_free(iter);<br>                       ast_debug(1, "Unregistered endpoint identifier %p\n", identifier);<br>-                 ast_module_unref(ast_module_info->self);<br>                   break;<br>                }<br>     }<br>@@ -3099,23 +3074,17 @@<br> <br> AST_RWLIST_HEAD_STATIC(endpoint_formatters, ast_sip_endpoint_formatter);<br> <br>-void internal_sip_register_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)<br>+void ast_sip_register_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)<br> {<br>    SCOPED_LOCK(lock, &endpoint_formatters, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);<br>    AST_RWLIST_INSERT_TAIL(&endpoint_formatters, obj, next);<br> }<br> <br>-int ast_sip_register_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)<br>-{<br>-    internal_sip_register_endpoint_formatter(obj);<br>-       ast_module_ref(ast_module_info->self);<br>-    return 0;<br>-}<br>-<br>-int internal_sip_unregister_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)<br>+void ast_sip_unregister_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)<br> {<br>    struct ast_sip_endpoint_formatter *i;<br>         SCOPED_LOCK(lock, &endpoint_formatters, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);<br>+<br>         AST_RWLIST_TRAVERSE_SAFE_BEGIN(&endpoint_formatters, i, next) {<br>           if (i == obj) {<br>                       AST_RWLIST_REMOVE_CURRENT(next);<br>@@ -3123,14 +3092,6 @@<br>              }<br>     }<br>     AST_RWLIST_TRAVERSE_SAFE_END;<br>-        return i == obj ? 0 : -1;<br>-}<br>-<br>-void ast_sip_unregister_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)<br>-{<br>-    if (!internal_sip_unregister_endpoint_formatter(obj)) {<br>-              ast_module_unref(ast_module_info->self);<br>-  }<br> }<br> <br> int ast_sip_format_endpoint_ami(struct ast_sip_endpoint *endpoint,<br>@@ -3817,7 +3778,7 @@<br> <br> AST_RWLIST_HEAD_STATIC(supplements, ast_sip_supplement);<br> <br>-void internal_sip_register_supplement(struct ast_sip_supplement *supplement)<br>+void ast_sip_register_supplement(struct ast_sip_supplement *supplement)<br> {<br>    struct ast_sip_supplement *iter;<br>      int inserted = 0;<br>@@ -3837,39 +3798,18 @@<br>    }<br> }<br> <br>-int __ast_sip_register_supplement(struct ast_sip_supplement *supplement,<br>-  const char *file, int line, const char *func)<br>-{<br>-    internal_sip_register_supplement(supplement);<br>-        __ast_module_ref(ast_module_info->self, file, line, func);<br>-<br>-     return 0;<br>-}<br>-<br>-int internal_sip_unregister_supplement(struct ast_sip_supplement *supplement)<br>+void ast_sip_unregister_supplement(struct ast_sip_supplement *supplement)<br> {<br>      struct ast_sip_supplement *iter;<br>      SCOPED_LOCK(lock, &supplements, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);<br>-   int res = -1;<br> <br>      AST_RWLIST_TRAVERSE_SAFE_BEGIN(&supplements, iter, next) {<br>                if (supplement == iter) {<br>                     AST_RWLIST_REMOVE_CURRENT(next);<br>-                     res = 0;<br>                      break;<br>                }<br>     }<br>     AST_RWLIST_TRAVERSE_SAFE_END;<br>-<br>-     return res;<br>-}<br>-<br>-void __ast_sip_unregister_supplement(struct ast_sip_supplement *supplement,<br>-     const char *file, int line, const char *func)<br>-{<br>-    if (!internal_sip_unregister_supplement(supplement)) {<br>-               __ast_module_unref(ast_module_info->self, file, line, func);<br>-      }<br> }<br> <br> static int send_in_dialog_request(pjsip_tx_data *tdata, struct pjsip_dialog *dlg)<br>@@ -4999,7 +4939,7 @@<br>           ast_res_pjsip_destroy_configuration();<br>                ast_sip_destroy_system();<br>             ast_sip_destroy_global_headers();<br>-            internal_sip_unregister_service(&supplement_module);<br>+             ast_sip_unregister_service(&supplement_module);<br>           ast_sip_destroy_transport_events();<br>   }<br> <br>@@ -5099,8 +5039,6 @@<br> {<br>       struct ast_threadpool_options options;<br> <br>-    CHECK_PJPROJECT_MODULE_LOADED();<br>-<br>   /* pjproject and config_system need to be initialized before all else */<br>      if (pj_init() != PJ_SUCCESS) {<br>                return AST_MODULE_LOAD_DECLINE;<br>@@ -5166,7 +5104,7 @@<br>                goto error;<br>   }<br> <br>- if (internal_sip_register_service(&supplement_module)) {<br>+ if (ast_sip_register_service(&supplement_module)) {<br>               ast_log(LOG_ERROR, "Failed to initialize supplement hooks. Aborting load\n");<br>               goto error;<br>   }<br>@@ -5182,8 +5120,6 @@<br> <br>   AST_TEST_REGISTER(xml_sanitization_end_null);<br>         AST_TEST_REGISTER(xml_sanitization_exceeds_buffer);<br>-<br>-       ast_pjproject_ref();<br> <br>       return AST_MODULE_LOAD_SUCCESS;<br> <br>@@ -5225,8 +5161,6 @@<br>     ast_sip_destroy_scheduler();<br>  serializer_pool_shutdown();<br>   ast_threadpool_shutdown(sip_threadpool);<br>-<br>-  ast_pjproject_unref();<br> <br>     return 0;<br> }<br>diff --git a/res/res_pjsip/config_auth.c b/res/res_pjsip/config_auth.c<br>index 4732681..b1bf9c4 100644<br>--- a/res/res_pjsip/config_auth.c<br>+++ b/res/res_pjsip/config_auth.c<br>@@ -374,7 +374,7 @@<br>       ast_sorcery_object_field_register_custom(sorcery, SIP_SORCERY_AUTH_TYPE, "auth_type",<br>                       "userpass", auth_type_handler, auth_type_to_str, NULL, 0, 0);<br> <br>-   internal_sip_register_endpoint_formatter(&endpoint_auth_formatter);<br>+      ast_sip_register_endpoint_formatter(&endpoint_auth_formatter);<br> <br>         cli_formatter = ao2_alloc(sizeof(struct ast_sip_cli_formatter_entry), NULL);<br>  if (!cli_formatter) {<br>@@ -403,7 +403,7 @@<br> {<br>        ast_cli_unregister_multiple(cli_commands, ARRAY_LEN(cli_commands));<br>   ast_sip_unregister_cli_formatter(cli_formatter);<br>-     internal_sip_unregister_endpoint_formatter(&endpoint_auth_formatter);<br>+    ast_sip_unregister_endpoint_formatter(&endpoint_auth_formatter);<br> <br>       ast_manager_unregister("PJSIPShowAuths");<br> <br>diff --git a/res/res_pjsip/config_transport.c b/res/res_pjsip/config_transport.c<br>index 63bf118..d08b33b 100644<br>--- a/res/res_pjsip/config_transport.c<br>+++ b/res/res_pjsip/config_transport.c<br>@@ -1435,7 +1435,7 @@<br>        ast_sorcery_object_field_register(sorcery, "transport", "allow_reload", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_transport, allow_reload));<br>   ast_sorcery_object_field_register(sorcery, "transport", "symmetric_transport", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_transport, symmetric_transport));<br> <br>- internal_sip_register_endpoint_formatter(&endpoint_transport_formatter);<br>+ ast_sip_register_endpoint_formatter(&endpoint_transport_formatter);<br> <br>    cli_formatter = ao2_alloc(sizeof(struct ast_sip_cli_formatter_entry), NULL);<br>  if (!cli_formatter) {<br>@@ -1465,7 +1465,7 @@<br>  ast_cli_unregister_multiple(cli_commands, ARRAY_LEN(cli_commands));<br>   ast_sip_unregister_cli_formatter(cli_formatter);<br> <br>-  internal_sip_unregister_endpoint_formatter(&endpoint_transport_formatter);<br>+       ast_sip_unregister_endpoint_formatter(&endpoint_transport_formatter);<br> <br>  ao2_ref(transport_states, -1);<br>        transport_states = NULL;<br>diff --git a/res/res_pjsip/include/res_pjsip_private.h b/res/res_pjsip/include/res_pjsip_private.h<br>index 5ce3c6f..7fafd80 100644<br>--- a/res/res_pjsip/include/res_pjsip_private.h<br>+++ b/res/res_pjsip/include/res_pjsip_private.h<br>@@ -314,55 +314,7 @@<br>  */<br> int sip_cli_print_system(struct ast_sip_cli_context *context);<br> <br>-/*!<br>- * \internal<br>- * \brief Used by res_pjsip.so to register a service without adding a self reference<br>- */<br>-int internal_sip_register_service(pjsip_module *module);<br>-<br>-/*!<br>- * \internal<br>- * \brief Used by res_pjsip.so to unregister a service without removing a self reference<br>- */<br>-int internal_sip_unregister_service(pjsip_module *module);<br>-<br>-/*!<br>- * \internal<br>- * \brief Used by res_pjsip.so to register a supplement without adding a self reference<br>- */<br>-void internal_sip_register_supplement(struct ast_sip_supplement *supplement);<br>-<br>-/*!<br>- * \internal<br>- * \brief Used by res_pjsip.so to unregister a supplement without removing a self reference<br>- */<br>-int internal_sip_unregister_supplement(struct ast_sip_supplement *supplement);<br>-<br>-/*!<br>- * \internal<br>- * \brief Used by res_pjsip.so to register an endpoint formatter without adding a self reference<br>- */<br>-void internal_sip_register_endpoint_formatter(struct ast_sip_endpoint_formatter *obj);<br>-<br>-/*!<br>- * \internal<br>- * \brief Used by res_pjsip.so to unregister a endpoint formatter without removing a self reference<br>- */<br>-int internal_sip_unregister_endpoint_formatter(struct ast_sip_endpoint_formatter *obj);<br>-<br> struct ast_sip_session_supplement;<br>-<br>-/*!<br>- * \internal<br>- * \brief Used by res_pjsip.so to register a session supplement without adding a self reference<br>- */<br>-void internal_sip_session_register_supplement(struct ast_sip_session_supplement *supplement);<br>-<br>-/*!<br>- * \internal<br>- * \brief Used by res_pjsip.so to unregister a session supplement without removing a self reference<br>- */<br>-int internal_sip_session_unregister_supplement(struct ast_sip_session_supplement *supplement);<br> <br> /*!<br>  * \internal<br>diff --git a/res/res_pjsip/location.c b/res/res_pjsip/location.c<br>index eb9e588..84f73c7 100644<br>--- a/res/res_pjsip/location.c<br>+++ b/res/res_pjsip/location.c<br>@@ -1346,7 +1346,7 @@<br>    ast_sorcery_object_field_register(sorcery, "aor", "outbound_proxy", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_aor, outbound_proxy));<br>   ast_sorcery_object_field_register(sorcery, "aor", "support_path", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_aor, support_path));<br> <br>-   internal_sip_register_endpoint_formatter(&endpoint_aor_formatter);<br>+       ast_sip_register_endpoint_formatter(&endpoint_aor_formatter);<br> <br>  contact_formatter = ao2_alloc(sizeof(struct ast_sip_cli_formatter_entry), NULL);<br>      if (!contact_formatter) {<br>@@ -1402,7 +1402,7 @@<br>      ast_sip_unregister_cli_formatter(aor_formatter);<br>      ast_manager_unregister("PJSIPShowAors");<br> <br>-        internal_sip_unregister_endpoint_formatter(&endpoint_aor_formatter);<br>+     ast_sip_unregister_endpoint_formatter(&endpoint_aor_formatter);<br> <br>        return 0;<br> }<br>diff --git a/res/res_pjsip/pjsip_distributor.c b/res/res_pjsip/pjsip_distributor.c<br>index b4828d8..c239c1a 100644<br>--- a/res/res_pjsip/pjsip_distributor.c<br>+++ b/res/res_pjsip/pjsip_distributor.c<br>@@ -1243,15 +1243,15 @@<br>           return -1;<br>    }<br> <br>- if (internal_sip_register_service(&distributor_mod)) {<br>+   if (ast_sip_register_service(&distributor_mod)) {<br>                 ast_sip_destroy_distributor();<br>                return -1;<br>    }<br>-    if (internal_sip_register_service(&endpoint_mod)) {<br>+      if (ast_sip_register_service(&endpoint_mod)) {<br>            ast_sip_destroy_distributor();<br>                return -1;<br>    }<br>-    if (internal_sip_register_service(&auth_mod)) {<br>+  if (ast_sip_register_service(&auth_mod)) {<br>                ast_sip_destroy_distributor();<br>                return -1;<br>    }<br>@@ -1282,9 +1282,9 @@<br>      ast_cli_unregister_multiple(cli_commands, ARRAY_LEN(cli_commands));<br>   ast_sip_unregister_cli_formatter(unid_formatter);<br> <br>- internal_sip_unregister_service(&auth_mod);<br>-      internal_sip_unregister_service(&endpoint_mod);<br>-  internal_sip_unregister_service(&distributor_mod);<br>+       ast_sip_unregister_service(&auth_mod);<br>+   ast_sip_unregister_service(&endpoint_mod);<br>+       ast_sip_unregister_service(&distributor_mod);<br> <br>  ao2_global_obj_release(artificial_auth);<br>      ao2_cleanup(artificial_endpoint);<br>diff --git a/res/res_pjsip/pjsip_global_headers.c b/res/res_pjsip/pjsip_global_headers.c<br>index 4de28b5..52075ae 100644<br>--- a/res/res_pjsip/pjsip_global_headers.c<br>+++ b/res/res_pjsip/pjsip_global_headers.c<br>@@ -165,7 +165,7 @@<br>       AST_RWLIST_HEAD_INIT(&request_headers);<br>   AST_RWLIST_HEAD_INIT(&response_headers);<br> <br>-      internal_sip_register_service(&global_header_mod);<br>+       ast_sip_register_service(&global_header_mod);<br> }<br> <br> static void destroy_headers(struct header_list *headers)<br>@@ -183,5 +183,5 @@<br>      destroy_headers(&request_headers);<br>        destroy_headers(&response_headers);<br> <br>-   internal_sip_unregister_service(&global_header_mod);<br>+     ast_sip_unregister_service(&global_header_mod);<br> }<br>diff --git a/res/res_pjsip/pjsip_message_filter.c b/res/res_pjsip/pjsip_message_filter.c<br>index 427aec7..f948c44 100644<br>--- a/res/res_pjsip/pjsip_message_filter.c<br>+++ b/res/res_pjsip/pjsip_message_filter.c<br>@@ -517,24 +517,24 @@<br> <br> void ast_res_pjsip_cleanup_message_filter(void)<br> {<br>-     internal_sip_unregister_service(&filter_module_tsx);<br>-     internal_sip_unregister_service(&filter_module_transport);<br>-       internal_sip_unregister_supplement(&filter_supplement);<br>-  internal_sip_session_unregister_supplement(&filter_session_supplement);<br>+  ast_sip_unregister_service(&filter_module_tsx);<br>+  ast_sip_unregister_service(&filter_module_transport);<br>+    ast_sip_unregister_supplement(&filter_supplement);<br>+       ast_sip_session_unregister_supplement(&filter_session_supplement);<br> }<br> <br> int ast_res_pjsip_init_message_filter(void)<br> {<br>-      internal_sip_session_register_supplement(&filter_session_supplement);<br>-    internal_sip_register_supplement(&filter_supplement);<br>+    ast_sip_session_register_supplement(&filter_session_supplement);<br>+ ast_sip_register_supplement(&filter_supplement);<br> <br>-      if (internal_sip_register_service(&filter_module_transport)) {<br>+   if (ast_sip_register_service(&filter_module_transport)) {<br>                 ast_log(LOG_ERROR, "Could not register message filter module for incoming and outgoing requests\n");<br>                ast_res_pjsip_cleanup_message_filter();<br>               return -1;<br>    }<br> <br>- if (internal_sip_register_service(&filter_module_tsx)) {<br>+ if (ast_sip_register_service(&filter_module_tsx)) {<br>               ast_log(LOG_ERROR, "Could not register message filter module for incoming and outgoing requests\n");<br>                ast_res_pjsip_cleanup_message_filter();<br>               return -1;<br>diff --git a/res/res_pjsip/pjsip_options.c b/res/res_pjsip/pjsip_options.c<br>index 3465eae..4ae1f31 100644<br>--- a/res/res_pjsip/pjsip_options.c<br>+++ b/res/res_pjsip/pjsip_options.c<br>@@ -1562,7 +1562,7 @@<br>                return -1;<br>    }<br> <br>- internal_sip_register_endpoint_formatter(&contact_status_formatter);<br>+     ast_sip_register_endpoint_formatter(&contact_status_formatter);<br>   ast_manager_register_xml("PJSIPQualify", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, ami_sip_qualify);<br>        ast_manager_register_xml("PJSIPShowContacts", EVENT_FLAG_SYSTEM, ami_show_contacts);<br>        ast_cli_register_multiple(cli_options, ARRAY_LEN(cli_options));<br>@@ -1578,7 +1578,7 @@<br>        ast_cli_unregister_multiple(cli_options, ARRAY_LEN(cli_options));<br>     ast_manager_unregister("PJSIPQualify");<br>     ast_manager_unregister("PJSIPShowContacts");<br>-       internal_sip_unregister_endpoint_formatter(&contact_status_formatter);<br>+   ast_sip_unregister_endpoint_formatter(&contact_status_formatter);<br> <br>      ast_sorcery_observer_remove(ast_sip_get_sorcery(), "aor", &observer_callbacks_options);<br>         pjsip_endpt_unregister_module(ast_sip_get_pjsip_endpoint(), &options_module);<br>diff --git a/res/res_pjsip/pjsip_session.c b/res/res_pjsip/pjsip_session.c<br>index 153561c..f3f3a4d 100644<br>--- a/res/res_pjsip/pjsip_session.c<br>+++ b/res/res_pjsip/pjsip_session.c<br>@@ -32,7 +32,7 @@<br> <br> AST_RWLIST_HEAD_STATIC(session_supplements, ast_sip_session_supplement);<br> <br>-void internal_sip_session_register_supplement(struct ast_sip_session_supplement *supplement)<br>+void ast_sip_session_register_supplement(struct ast_sip_session_supplement *supplement)<br> {<br>       struct ast_sip_session_supplement *iter;<br>      int inserted = 0;<br>@@ -56,39 +56,18 @@<br>        }<br> }<br> <br>-int __ast_sip_session_register_supplement(struct ast_sip_session_supplement *supplement,<br>-  const char *file, int line, const char *func)<br>-{<br>-    internal_sip_session_register_supplement(supplement);<br>-        __ast_module_ref(AST_MODULE_SELF, file, line, func);<br>-<br>-      return 0;<br>-}<br>-<br>-int internal_sip_session_unregister_supplement(struct ast_sip_session_supplement *supplement)<br>+void ast_sip_session_unregister_supplement(struct ast_sip_session_supplement *supplement)<br> {<br>      struct ast_sip_session_supplement *iter;<br>-     int res = -1;<br>         SCOPED_LOCK(lock, &session_supplements, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);<br> <br>         AST_RWLIST_TRAVERSE_SAFE_BEGIN(&session_supplements, iter, next) {<br>                if (supplement == iter) {<br>                     AST_RWLIST_REMOVE_CURRENT(next);<br>-                     res = 0;<br>                      break;<br>                }<br>     }<br>     AST_RWLIST_TRAVERSE_SAFE_END;<br>-<br>-     return res;<br>-}<br>-<br>-void __ast_sip_session_unregister_supplement(struct ast_sip_session_supplement *supplement,<br>-     const char *file, int line, const char *func)<br>-{<br>-    if (!internal_sip_session_unregister_supplement(supplement)) {<br>-               __ast_module_unref(AST_MODULE_SELF, file, line, func);<br>-       }<br> }<br> <br> static struct ast_sip_session_supplement *supplement_dup(const struct ast_sip_session_supplement *src)<br>diff --git a/res/res_pjsip_acl.c b/res/res_pjsip_acl.c<br>index 9269864..8caf703 100644<br>--- a/res/res_pjsip_acl.c<br>+++ b/res/res_pjsip_acl.c<br>@@ -282,8 +282,6 @@<br> <br> static int load_module(void)<br> {<br>-    CHECK_PJSIP_MODULE_LOADED();<br>-<br>       ast_sorcery_apply_config(ast_sip_get_sorcery(), SIP_SORCERY_ACL_TYPE);<br>        ast_sorcery_apply_default(ast_sip_get_sorcery(), SIP_SORCERY_ACL_TYPE,<br>                                  "config", "pjsip.conf,criteria=type=acl");<br>diff --git a/res/res_pjsip_authenticator_digest.c b/res/res_pjsip_authenticator_digest.c<br>index b6f2b74..518ef73 100644<br>--- a/res/res_pjsip_authenticator_digest.c<br>+++ b/res/res_pjsip_authenticator_digest.c<br>@@ -524,8 +524,6 @@<br> <br> static int load_module(void)<br> {<br>- CHECK_PJSIP_MODULE_LOADED();<br>-<br>       if (build_entity_id()) {<br>              return AST_MODULE_LOAD_DECLINE;<br>       }<br>diff --git a/res/res_pjsip_caller_id.c b/res/res_pjsip_caller_id.c<br>index 1673147..f15a66c 100644<br>--- a/res/res_pjsip_caller_id.c<br>+++ b/res/res_pjsip_caller_id.c<br>@@ -746,8 +746,6 @@<br> <br> static int load_module(void)<br> {<br>-    CHECK_PJSIP_SESSION_MODULE_LOADED();<br>-<br>       ast_sip_session_register_supplement(&caller_id_supplement);<br>       return AST_MODULE_LOAD_SUCCESS;<br> }<br>diff --git a/res/res_pjsip_dialog_info_body_generator.c b/res/res_pjsip_dialog_info_body_generator.c<br>index 866ea9d..a13995f 100644<br>--- a/res/res_pjsip_dialog_info_body_generator.c<br>+++ b/res/res_pjsip_dialog_info_body_generator.c<br>@@ -198,8 +198,6 @@<br> <br> static int load_module(void)<br> {<br>-      CHECK_PJSIP_PUBSUB_MODULE_LOADED();<br>-<br>        if (ast_sip_pubsub_register_body_generator(&dialog_info_body_generator)) {<br>                return AST_MODULE_LOAD_DECLINE;<br>       }<br>diff --git a/res/res_pjsip_diversion.c b/res/res_pjsip_diversion.c<br>index 84c42dc..e82140b 100644<br>--- a/res/res_pjsip_diversion.c<br>+++ b/res/res_pjsip_diversion.c<br>@@ -411,8 +411,6 @@<br> <br> static int load_module(void)<br> {<br>-    CHECK_PJSIP_SESSION_MODULE_LOADED();<br>-<br>       ast_sip_session_register_supplement(&diversion_supplement);<br>       return AST_MODULE_LOAD_SUCCESS;<br> }<br>@@ -428,5 +426,5 @@<br>      .load = load_module,<br>  .unload = unload_module,<br>      .load_pri = AST_MODPRI_APP_DEPEND,<br>-   .requires = "res_pjsip",<br>+   .requires = "res_pjsip,res_pjsip_session",<br> );<br>diff --git a/res/res_pjsip_dlg_options.c b/res/res_pjsip_dlg_options.c<br>index 565ad2a..93e3f22 100644<br>--- a/res/res_pjsip_dlg_options.c<br>+++ b/res/res_pjsip_dlg_options.c<br>@@ -83,11 +83,8 @@<br> <br> static int load_module(void)<br> {<br>-     CHECK_PJSIP_MODULE_LOADED();<br>+ ast_sip_session_register_supplement(&dlg_options_supplement);<br> <br>- if (ast_sip_session_register_supplement(&dlg_options_supplement)) {<br>-              return AST_MODULE_LOAD_DECLINE;<br>-      }<br>     return AST_MODULE_LOAD_SUCCESS;<br> }<br> <br>diff --git a/res/res_pjsip_dtmf_info.c b/res/res_pjsip_dtmf_info.c<br>index 68df617..983498d 100644<br>--- a/res/res_pjsip_dtmf_info.c<br>+++ b/res/res_pjsip_dtmf_info.c<br>@@ -160,8 +160,6 @@<br> <br> static int load_module(void)<br> {<br>-       CHECK_PJSIP_SESSION_MODULE_LOADED();<br>-<br>       ast_sip_session_register_supplement(&dtmf_info_supplement);<br>       return AST_MODULE_LOAD_SUCCESS;<br> }<br>@@ -177,5 +175,5 @@<br>      .load = load_module,<br>  .unload = unload_module,<br>      .load_pri = AST_MODPRI_APP_DEPEND,<br>-   .requires = "res_pjsip",<br>+   .requires = "res_pjsip,res_pjsip_session",<br> );<br>diff --git a/res/res_pjsip_empty_info.c b/res/res_pjsip_empty_info.c<br>index c67835c..74e5729 100644<br>--- a/res/res_pjsip_empty_info.c<br>+++ b/res/res_pjsip_empty_info.c<br>@@ -66,8 +66,6 @@<br> <br> static int load_module(void)<br> {<br>-  CHECK_PJSIP_SESSION_MODULE_LOADED();<br>-<br>       ast_sip_session_register_supplement(&empty_info_supplement);<br>      return AST_MODULE_LOAD_SUCCESS;<br> }<br>@@ -83,5 +81,5 @@<br>        .load = load_module,<br>  .unload = unload_module,<br>      .load_pri = AST_MODPRI_APP_DEPEND,<br>-   .requires = "res_pjsip",<br>+   .requires = "res_pjsip,res_pjsip_session",<br> );<br>diff --git a/res/res_pjsip_endpoint_identifier_anonymous.c b/res/res_pjsip_endpoint_identifier_anonymous.c<br>index 16662eb..918aec5 100644<br>--- a/res/res_pjsip_endpoint_identifier_anonymous.c<br>+++ b/res/res_pjsip_endpoint_identifier_anonymous.c<br>@@ -116,8 +116,6 @@<br> <br> static int load_module(void)<br> {<br>-    CHECK_PJSIP_MODULE_LOADED();<br>-<br>       ast_sip_register_endpoint_identifier_with_name(&anonymous_identifier, "anonymous");<br>     return AST_MODULE_LOAD_SUCCESS;<br> }<br>diff --git a/res/res_pjsip_endpoint_identifier_ip.c b/res/res_pjsip_endpoint_identifier_ip.c<br>index ee47e4d..555d653 100644<br>--- a/res/res_pjsip_endpoint_identifier_ip.c<br>+++ b/res/res_pjsip_endpoint_identifier_ip.c<br>@@ -717,8 +717,6 @@<br> <br> static int load_module(void)<br> {<br>-      CHECK_PJSIP_MODULE_LOADED();<br>-<br>       ast_sorcery_apply_config(ast_sip_get_sorcery(), "res_pjsip_endpoint_identifier_ip");<br>        ast_sorcery_apply_default(ast_sip_get_sorcery(), "identify", "config", "pjsip.conf,criteria=type=identify");<br> <br>diff --git a/res/res_pjsip_endpoint_identifier_user.c b/res/res_pjsip_endpoint_identifier_user.c<br>index 1b0c7d9..e18d2fa 100644<br>--- a/res/res_pjsip_endpoint_identifier_user.c<br>+++ b/res/res_pjsip_endpoint_identifier_user.c<br>@@ -195,8 +195,6 @@<br> <br> static int load_module(void)<br> {<br>-    CHECK_PJSIP_MODULE_LOADED();<br>-<br>       ast_sip_register_endpoint_identifier_with_name(&username_identifier, "username");<br>       ast_sip_register_endpoint_identifier_with_name(&auth_username_identifier, "auth_username");<br>     return AST_MODULE_LOAD_SUCCESS;<br>diff --git a/res/res_pjsip_exten_state.c b/res/res_pjsip_exten_state.c<br>index e70eba7..47ec8b4 100644<br>--- a/res/res_pjsip_exten_state.c<br>+++ b/res/res_pjsip_exten_state.c<br>@@ -959,13 +959,6 @@<br> <br> static int load_module(void)<br> {<br>-     CHECK_PJSIP_PUBSUB_MODULE_LOADED();<br>-<br>-       if (!ast_module_check("res_pjsip_outbound_publish.so")) {<br>-          ast_log(LOG_WARNING, "This module requires the 'res_pjsip_outbound_publish.so' module to be loaded\n");<br>-            return AST_MODULE_LOAD_DECLINE;<br>-      }<br>-<br>  publishers = ao2_container_alloc(PUBLISHER_BUCKETS, exten_state_publisher_hash,<br>               exten_state_publisher_cmp);<br>   if (!publishers) {<br>diff --git a/res/res_pjsip_header_funcs.c b/res/res_pjsip_header_funcs.c<br>index 06fba06..7930263 100644<br>--- a/res/res_pjsip_header_funcs.c<br>+++ b/res/res_pjsip_header_funcs.c<br>@@ -609,8 +609,6 @@<br> <br> static int load_module(void)<br> {<br>-       CHECK_PJSIP_SESSION_MODULE_LOADED();<br>-<br>       ast_sip_session_register_supplement(&header_funcs_supplement);<br>    ast_custom_function_register(&pjsip_header_function);<br> <br>diff --git a/res/res_pjsip_history.c b/res/res_pjsip_history.c<br>index 40d26d5..fa9e27f 100644<br>--- a/res/res_pjsip_history.c<br>+++ b/res/res_pjsip_history.c<br>@@ -1364,8 +1364,6 @@<br> <br> static int load_module(void)<br> {<br>-       CHECK_PJSIP_MODULE_LOADED();<br>-<br>       log_level = ast_logger_register_level("PJSIP_HISTORY");<br>     if (log_level < 0) {<br>               ast_log(LOG_WARNING, "Unable to register history log level\n");<br>diff --git a/res/res_pjsip_logger.c b/res/res_pjsip_logger.c<br>index 460b6a3..49ad6fa 100644<br>--- a/res/res_pjsip_logger.c<br>+++ b/res/res_pjsip_logger.c<br>@@ -231,8 +231,6 @@<br> <br> static int load_module(void)<br> {<br>-        CHECK_PJSIP_MODULE_LOADED();<br>-<br>       if (ast_sorcery_observer_add(ast_sip_get_sorcery(), "global", &global_observer)) {<br>              ast_log(LOG_WARNING, "Unable to add global observer\n");<br>            return AST_MODULE_LOAD_DECLINE;<br>diff --git a/res/res_pjsip_messaging.c b/res/res_pjsip_messaging.c<br>index 3739bcf..cbaed83 100644<br>--- a/res/res_pjsip_messaging.c<br>+++ b/res/res_pjsip_messaging.c<br>@@ -805,8 +805,6 @@<br> <br> static int load_module(void)<br> {<br>-      CHECK_PJSIP_SESSION_MODULE_LOADED();<br>-<br>       if (ast_sip_register_service(&messaging_module) != PJ_SUCCESS) {<br>          return AST_MODULE_LOAD_DECLINE;<br>       }<br>@@ -849,5 +847,5 @@<br>        .load = load_module,<br>  .unload = unload_module,<br>      .load_pri = AST_MODPRI_APP_DEPEND,<br>-   .requires = "res_pjsip",<br>+   .requires = "res_pjsip,res_pjsip_session",<br> );<br>diff --git a/res/res_pjsip_mwi.c b/res/res_pjsip_mwi.c<br>index 92dc7dc..90fdc09 100644<br>--- a/res/res_pjsip_mwi.c<br>+++ b/res/res_pjsip_mwi.c<br>@@ -1339,8 +1339,6 @@<br> <br> static int load_module(void)<br> {<br>-  CHECK_PJSIP_MODULE_LOADED();<br>-<br>       if (ast_sip_register_subscription_handler(&mwi_handler)) {<br>                return AST_MODULE_LOAD_DECLINE;<br>       }<br>diff --git a/res/res_pjsip_mwi_body_generator.c b/res/res_pjsip_mwi_body_generator.c<br>index 65ac600..29b2ed0 100644<br>--- a/res/res_pjsip_mwi_body_generator.c<br>+++ b/res/res_pjsip_mwi_body_generator.c<br>@@ -97,8 +97,6 @@<br> <br> static int load_module(void)<br> {<br>-  CHECK_PJSIP_PUBSUB_MODULE_LOADED();<br>-<br>        if (ast_sip_pubsub_register_body_generator(&mwi_generator)) {<br>             return AST_MODULE_LOAD_DECLINE;<br>       }<br>diff --git a/res/res_pjsip_nat.c b/res/res_pjsip_nat.c<br>index 4231a1e..1d42805 100644<br>--- a/res/res_pjsip_nat.c<br>+++ b/res/res_pjsip_nat.c<br>@@ -357,18 +357,12 @@<br> <br> static int load_module(void)<br> {<br>-  CHECK_PJSIP_SESSION_MODULE_LOADED();<br>-<br>       if (ast_sip_register_service(&nat_module)) {<br>              ast_log(LOG_ERROR, "Could not register NAT module for incoming and outgoing requests\n");<br>           return AST_MODULE_LOAD_DECLINE;<br>       }<br> <br>- if (ast_sip_session_register_supplement(&nat_supplement)) {<br>-              ast_log(LOG_ERROR, "Could not register NAT session supplement for incoming and outgoing INVITE requests\n");<br>-               unload_module();<br>-             return AST_MODULE_LOAD_DECLINE;<br>-      }<br>+    ast_sip_session_register_supplement(&nat_supplement);<br> <br>  return AST_MODULE_LOAD_SUCCESS;<br> }<br>@@ -378,5 +372,5 @@<br>      .load = load_module,<br>  .unload = unload_module,<br>      .load_pri = AST_MODPRI_APP_DEPEND,<br>-   .requires = "res_pjsip",<br>+   .requires = "res_pjsip,res_pjsip_session",<br> );<br>diff --git a/res/res_pjsip_notify.c b/res/res_pjsip_notify.c<br>index 9767c56..253cf9a 100644<br>--- a/res/res_pjsip_notify.c<br>+++ b/res/res_pjsip_notify.c<br>@@ -987,8 +987,6 @@<br> <br> static int load_module(void)<br> {<br>-        CHECK_PJSIP_MODULE_LOADED();<br>-<br>       if (aco_info_init(&notify_cfg)) {<br>                 return AST_MODULE_LOAD_DECLINE;<br>       }<br>diff --git a/res/res_pjsip_one_touch_record_info.c b/res/res_pjsip_one_touch_record_info.c<br>index ef59fca..50f2a38 100644<br>--- a/res/res_pjsip_one_touch_record_info.c<br>+++ b/res/res_pjsip_one_touch_record_info.c<br>@@ -107,12 +107,7 @@<br> <br> static int load_module(void)<br> {<br>-   CHECK_PJSIP_SESSION_MODULE_LOADED();<br>-<br>-      if (ast_sip_session_register_supplement(&info_supplement)) {<br>-             ast_log(LOG_ERROR, "Unable to register One Touch Recording supplement\n");<br>-         return AST_MODULE_LOAD_DECLINE;<br>-      }<br>+    ast_sip_session_register_supplement(&info_supplement);<br> <br>         return AST_MODULE_LOAD_SUCCESS;<br> }<br>@@ -128,5 +123,5 @@<br>      .load = load_module,<br>  .unload = unload_module,<br>      .load_pri = AST_MODPRI_APP_DEPEND,<br>-   .requires = "res_pjsip",<br>+   .requires = "res_pjsip,res_pjsip_session",<br> );<br>diff --git a/res/res_pjsip_outbound_authenticator_digest.c b/res/res_pjsip_outbound_authenticator_digest.c<br>index 54bba08..063b4d3 100644<br>--- a/res/res_pjsip_outbound_authenticator_digest.c<br>+++ b/res/res_pjsip_outbound_authenticator_digest.c<br>@@ -205,8 +205,6 @@<br> <br> static int load_module(void)<br> {<br>-    CHECK_PJSIP_MODULE_LOADED();<br>-<br>       if (ast_sip_register_outbound_authenticator(&digest_authenticator)) {<br>             return AST_MODULE_LOAD_DECLINE;<br>       }<br>diff --git a/res/res_pjsip_outbound_publish.c b/res/res_pjsip_outbound_publish.c<br>index b4e3320..75e74a2 100644<br>--- a/res/res_pjsip_outbound_publish.c<br>+++ b/res/res_pjsip_outbound_publish.c<br>@@ -345,7 +345,6 @@<br> static void sub_add_handler(struct ast_sip_event_publisher_handler *handler)<br> {<br>    AST_RWLIST_INSERT_TAIL(&publisher_handlers, handler, next);<br>-      ast_module_ref(ast_module_info->self);<br> }<br> <br> static struct ast_sip_event_publisher_handler *find_publisher_handler_for_event_name(const char *event_name)<br>@@ -643,7 +642,6 @@<br>  AST_RWLIST_TRAVERSE_SAFE_BEGIN(&publisher_handlers, iter, next) {<br>                 if (handler == iter) {<br>                        AST_RWLIST_REMOVE_CURRENT(next);<br>-                     ast_module_unref(ast_module_info->self);<br>                   break;<br>                }<br>     }<br>@@ -1643,8 +1641,6 @@<br> <br> static int load_module(void)<br> {<br>-       CHECK_PJSIP_MODULE_LOADED();<br>-<br>       /* As of pjproject 2.4.5, PJSIP_MAX_URL_SIZE isn't exposed yet but we try anyway. */<br>      ast_pjproject_get_buildopt("PJSIP_MAX_URL_SIZE", "%d", &pjsip_max_url_size);<br> <br>diff --git a/res/res_pjsip_outbound_registration.c b/res/res_pjsip_outbound_registration.c<br>index 79bea48..5367033 100644<br>--- a/res/res_pjsip_outbound_registration.c<br>+++ b/res/res_pjsip_outbound_registration.c<br>@@ -2177,8 +2177,6 @@<br> {<br>       struct ao2_container *new_states;<br> <br>- CHECK_PJSIP_MODULE_LOADED();<br>-<br>       shutdown_group = ast_serializer_shutdown_group_alloc();<br>       if (!shutdown_group) {<br>                return AST_MODULE_LOAD_DECLINE;<br>diff --git a/res/res_pjsip_path.c b/res/res_pjsip_path.c<br>index b245f15..3c545f9 100644<br>--- a/res/res_pjsip_path.c<br>+++ b/res/res_pjsip_path.c<br>@@ -238,16 +238,8 @@<br> <br> static int load_module(void)<br> {<br>- CHECK_PJSIP_SESSION_MODULE_LOADED();<br>-<br>-      if (ast_sip_register_supplement(&path_supplement)) {<br>-             return AST_MODULE_LOAD_DECLINE;<br>-      }<br>-<br>- if (ast_sip_session_register_supplement(&path_session_supplement)) {<br>-             ast_sip_unregister_supplement(&path_supplement);<br>-         return AST_MODULE_LOAD_DECLINE;<br>-      }<br>+    ast_sip_register_supplement(&path_supplement);<br>+   ast_sip_session_register_supplement(&path_session_supplement);<br> <br>         return AST_MODULE_LOAD_SUCCESS;<br> }<br>@@ -264,5 +256,5 @@<br>      .load = load_module,<br>  .unload = unload_module,<br>      .load_pri = AST_MODPRI_APP_DEPEND,<br>-   .requires = "res_pjsip",<br>+   .requires = "res_pjsip,res_pjsip_session",<br> );<br>diff --git a/res/res_pjsip_phoneprov_provider.c b/res/res_pjsip_phoneprov_provider.c<br>index 11031c3..acb1e68 100644<br>--- a/res/res_pjsip_phoneprov_provider.c<br>+++ b/res/res_pjsip_phoneprov_provider.c<br>@@ -367,8 +367,6 @@<br> <br> static int load_module(void)<br> {<br>-        CHECK_PJSIP_MODULE_LOADED();<br>-<br>       sorcery = ast_sip_get_sorcery();<br> <br>   ast_sorcery_apply_config(sorcery, "res_pjsip_phoneprov_provider");<br>diff --git a/res/res_pjsip_pidf_body_generator.c b/res/res_pjsip_pidf_body_generator.c<br>index 6426dfa..8bc062e 100644<br>--- a/res/res_pjsip_pidf_body_generator.c<br>+++ b/res/res_pjsip_pidf_body_generator.c<br>@@ -116,8 +116,6 @@<br> <br> static int load_module(void)<br> {<br>- CHECK_PJSIP_PUBSUB_MODULE_LOADED();<br>-<br>        if (ast_sip_pubsub_register_body_generator(&pidf_body_generator)) {<br>               return AST_MODULE_LOAD_DECLINE;<br>       }<br>diff --git a/res/res_pjsip_pidf_digium_body_supplement.c b/res/res_pjsip_pidf_digium_body_supplement.c<br>index f855e21..832f423 100644<br>--- a/res/res_pjsip_pidf_digium_body_supplement.c<br>+++ b/res/res_pjsip_pidf_digium_body_supplement.c<br>@@ -95,8 +95,6 @@<br> <br> static int load_module(void)<br> {<br>-      CHECK_PJSIP_PUBSUB_MODULE_LOADED();<br>-<br>        if (ast_sip_pubsub_register_body_supplement(&pidf_supplement)) {<br>          return AST_MODULE_LOAD_DECLINE;<br>       }<br>diff --git a/res/res_pjsip_pidf_eyebeam_body_supplement.c b/res/res_pjsip_pidf_eyebeam_body_supplement.c<br>index 6629aa3..15446bc 100644<br>--- a/res/res_pjsip_pidf_eyebeam_body_supplement.c<br>+++ b/res/res_pjsip_pidf_eyebeam_body_supplement.c<br>@@ -92,8 +92,6 @@<br> <br> static int load_module(void)<br> {<br>-  CHECK_PJSIP_PUBSUB_MODULE_LOADED();<br>-<br>        if (ast_sip_pubsub_register_body_supplement(&pidf_supplement)) {<br>          return AST_MODULE_LOAD_DECLINE;<br>       }<br>diff --git a/res/res_pjsip_publish_asterisk.c b/res/res_pjsip_publish_asterisk.c<br>index 13d7fd4..220ba0b 100644<br>--- a/res/res_pjsip_publish_asterisk.c<br>+++ b/res/res_pjsip_publish_asterisk.c<br>@@ -855,8 +855,6 @@<br> <br> static int load_module(void)<br> {<br>-        CHECK_PJSIP_PUBSUB_MODULE_LOADED();<br>-<br>        if (ast_eid_is_empty(&ast_eid_default)) {<br>                 ast_log(LOG_ERROR, "Entity ID is not set.\n");<br>              return AST_MODULE_LOAD_DECLINE;<br>diff --git a/res/res_pjsip_pubsub.c b/res/res_pjsip_pubsub.c<br>index af696b8..369e06d 100644<br>--- a/res/res_pjsip_pubsub.c<br>+++ b/res/res_pjsip_pubsub.c<br>@@ -2583,8 +2583,6 @@<br> <br>    publish_add_handler(handler);<br> <br>-     ast_module_ref(ast_module_info->self);<br>-<br>  return 0;<br> }<br> <br>@@ -2597,7 +2595,6 @@<br>               if (handler == iter) {<br>                        AST_RWLIST_REMOVE_CURRENT(next);<br>                      ao2_cleanup(handler->publications);<br>-                       ast_module_unref(ast_module_info->self);<br>                   break;<br>                }<br>     }<br>@@ -2611,7 +2608,6 @@<br> {<br>  AST_RWLIST_WRLOCK(&subscription_handlers);<br>        AST_RWLIST_INSERT_TAIL(&subscription_handlers, handler, next);<br>-   ast_module_ref(ast_module_info->self);<br>     AST_RWLIST_UNLOCK(&subscription_handlers);<br> }<br> <br>@@ -2670,7 +2666,6 @@<br>  AST_RWLIST_TRAVERSE_SAFE_BEGIN(&subscription_handlers, iter, next) {<br>              if (handler == iter) {<br>                        AST_RWLIST_REMOVE_CURRENT(next);<br>-                     ast_module_unref(ast_module_info->self);<br>                   break;<br>                }<br>     }<br>@@ -5377,8 +5372,6 @@<br> {<br>  static const pj_str_t str_PUBLISH = { "PUBLISH", 7 };<br>       struct ast_sorcery *sorcery;<br>-<br>-      CHECK_PJSIP_MODULE_LOADED();<br> <br>       sorcery = ast_sip_get_sorcery();<br> <br>diff --git a/res/res_pjsip_refer.c b/res/res_pjsip_refer.c<br>index 3100993..5e0141b 100644<br>--- a/res/res_pjsip_refer.c<br>+++ b/res/res_pjsip_refer.c<br>@@ -1202,8 +1202,6 @@<br> {<br>   const pj_str_t str_norefersub = { "norefersub", 10 };<br> <br>-   CHECK_PJSIP_SESSION_MODULE_LOADED();<br>-<br>       pjsip_replaces_init_module(ast_sip_get_pjsip_endpoint());<br>     pjsip_xfer_init_module(ast_sip_get_pjsip_endpoint());<br>         pjsip_endpt_add_capability(ast_sip_get_pjsip_endpoint(), NULL, PJSIP_H_SUPPORTED, NULL, 1, &str_norefersub);<br>diff --git a/res/res_pjsip_registrar.c b/res/res_pjsip_registrar.c<br>index 7277a5f..00981fb 100644<br>--- a/res/res_pjsip_registrar.c<br>+++ b/res/res_pjsip_registrar.c<br>@@ -1095,13 +1095,9 @@<br> {<br>     const pj_str_t STR_REGISTER = { "REGISTER", 8 };<br> <br>-        CHECK_PJPROJECT_MODULE_LOADED();<br>-<br>   ast_pjproject_get_buildopt("PJ_MAX_HOSTNAME", "%d", &pj_max_hostname);<br>        /* As of pjproject 2.4.5, PJSIP_MAX_URL_SIZE isn't exposed yet but we try anyway. */<br>      ast_pjproject_get_buildopt("PJSIP_MAX_URL_SIZE", "%d", &pjsip_max_url_size);<br>-<br>-      CHECK_PJSIP_MODULE_LOADED();<br> <br>       if (ast_sip_register_service(&registrar_module)) {<br>                return AST_MODULE_LOAD_DECLINE;<br>diff --git a/res/res_pjsip_registrar_expire.c b/res/res_pjsip_registrar_expire.c<br>index 85e3fb8..e89ea03 100644<br>--- a/res/res_pjsip_registrar_expire.c<br>+++ b/res/res_pjsip_registrar_expire.c<br>@@ -137,8 +137,6 @@<br> <br> static int load_module(void)<br> {<br>-  CHECK_PJSIP_MODULE_LOADED();<br>-<br>       ast_sorcery_observer_add(ast_sip_get_sorcery(), "global", &expiration_global_observer);<br>         ast_sorcery_reload_object(ast_sip_get_sorcery(), "global");<br> <br>diff --git a/res/res_pjsip_rfc3326.c b/res/res_pjsip_rfc3326.c<br>index 8b8035e..6c02a17 100644<br>--- a/res/res_pjsip_rfc3326.c<br>+++ b/res/res_pjsip_rfc3326.c<br>@@ -138,8 +138,6 @@<br> <br> static int load_module(void)<br> {<br>-     CHECK_PJSIP_SESSION_MODULE_LOADED();<br>-<br>       ast_sip_session_register_supplement(&rfc3326_supplement);<br>         return AST_MODULE_LOAD_SUCCESS;<br> }<br>@@ -155,5 +153,5 @@<br>      .load = load_module,<br>  .unload = unload_module,<br>      .load_pri = AST_MODPRI_APP_DEPEND,<br>-   .requires = "res_pjsip",<br>+   .requires = "res_pjsip,res_pjsip_session",<br> );<br>diff --git a/res/res_pjsip_sdp_rtp.c b/res/res_pjsip_sdp_rtp.c<br>index 3cc9764..ce8ed82 100644<br>--- a/res/res_pjsip_sdp_rtp.c<br>+++ b/res/res_pjsip_sdp_rtp.c<br>@@ -1928,8 +1928,6 @@<br>  */<br> static int load_module(void)<br> {<br>-       CHECK_PJSIP_SESSION_MODULE_LOADED();<br>-<br>       if (ast_check_ipv6()) {<br>               ast_sockaddr_parse(&address_rtp, "::", 0);<br>      } else {<br>diff --git a/res/res_pjsip_send_to_voicemail.c b/res/res_pjsip_send_to_voicemail.c<br>index 06c3edc..d689602 100644<br>--- a/res/res_pjsip_send_to_voicemail.c<br>+++ b/res/res_pjsip_send_to_voicemail.c<br>@@ -215,12 +215,7 @@<br> <br> static int load_module(void)<br> {<br>-    CHECK_PJSIP_SESSION_MODULE_LOADED();<br>-<br>-      if (ast_sip_session_register_supplement(&refer_supplement)) {<br>-            ast_log(LOG_ERROR, "Unable to register Send to Voicemail supplement\n");<br>-           return AST_MODULE_LOAD_DECLINE;<br>-      }<br>+    ast_sip_session_register_supplement(&refer_supplement);<br> <br>        return AST_MODULE_LOAD_SUCCESS;<br> }<br>diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c<br>index 8247fba..4d4ed47 100644<br>--- a/res/res_pjsip_session.c<br>+++ b/res/res_pjsip_session.c<br>@@ -124,7 +124,7 @@<br>                 }<br>             AST_LIST_INSERT_TAIL(&handler_list->list, handler, next);<br>              ast_debug(1, "Registered SDP stream handler '%s' for stream type '%s'\n", handler->id, stream_type);<br>-            ast_module_ref(ast_module_info->self);<br>+<br>          return 0;<br>     }<br> <br>@@ -141,7 +141,7 @@<br>             return -1;<br>    }<br>     ast_debug(1, "Registered SDP stream handler '%s' for stream type '%s'\n", handler->id, stream_type);<br>-    ast_module_ref(ast_module_info->self);<br>+<br>  return 0;<br> }<br> <br>@@ -156,7 +156,6 @@<br>                 if (!strcmp(iter->id, handler->id)) {<br>                   AST_LIST_REMOVE_CURRENT(next);<br>                        ast_debug(1, "Unregistered SDP stream handler '%s' for stream type '%s'\n", handler->id, stream_type);<br>-                  ast_module_unref(ast_module_info->self);<br>           }<br>     }<br>     AST_LIST_TRAVERSE_SAFE_END;<br>@@ -4155,8 +4154,6 @@<br> static int load_module(void)<br> {<br>         pjsip_endpoint *endpt;<br>-<br>-    CHECK_PJSIP_MODULE_LOADED();<br> <br>       if (!ast_sip_get_sorcery() || !ast_sip_get_pjsip_endpoint()) {<br>                return AST_MODULE_LOAD_DECLINE;<br>diff --git a/res/res_pjsip_sips_contact.c b/res/res_pjsip_sips_contact.c<br>index 41b26df..7c0ff43 100644<br>--- a/res/res_pjsip_sips_contact.c<br>+++ b/res/res_pjsip_sips_contact.c<br>@@ -90,8 +90,6 @@<br> <br> static int load_module(void)<br> {<br>-    CHECK_PJSIP_MODULE_LOADED();<br>-<br>       if (ast_sip_register_service(&sips_contact_module)) {<br>             return AST_MODULE_LOAD_DECLINE;<br>       }<br>diff --git a/res/res_pjsip_t38.c b/res/res_pjsip_t38.c<br>index 7b7cd99..249472b 100644<br>--- a/res/res_pjsip_t38.c<br>+++ b/res/res_pjsip_t38.c<br>@@ -1023,18 +1023,13 @@<br>  */<br> static int load_module(void)<br> {<br>-     CHECK_PJSIP_SESSION_MODULE_LOADED();<br>-<br>       if (ast_check_ipv6()) {<br>               ast_sockaddr_parse(&address, "::", 0);<br>  } else {<br>              ast_sockaddr_parse(&address, "0.0.0.0", 0);<br>     }<br> <br>- if (ast_sip_session_register_supplement(&t38_supplement)) {<br>-              ast_log(LOG_ERROR, "Unable to register T.38 session supplement\n");<br>-                goto end;<br>-    }<br>+    ast_sip_session_register_supplement(&t38_supplement);<br> <br>  if (ast_sip_session_register_sdp_handler(&image_sdp_handler, "image")) {<br>                ast_log(LOG_ERROR, "Unable to register SDP handler for image stream type\n");<br>diff --git a/res/res_pjsip_transport_management.c b/res/res_pjsip_transport_management.c<br>index acffb86..afaa248 100644<br>--- a/res/res_pjsip_transport_management.c<br>+++ b/res/res_pjsip_transport_management.c<br>@@ -323,8 +323,6 @@<br> {<br>     struct ao2_container *transports;<br> <br>- CHECK_PJSIP_MODULE_LOADED();<br>-<br>       transports = ao2_container_alloc(TRANSPORTS_BUCKETS, monitored_transport_hash_fn,<br>             monitored_transport_cmp_fn);<br>  if (!transports) {<br>diff --git a/res/res_pjsip_transport_websocket.c b/res/res_pjsip_transport_websocket.c<br>index af1345f..974b150 100644<br>--- a/res/res_pjsip_transport_websocket.c<br>+++ b/res/res_pjsip_transport_websocket.c<br>@@ -471,8 +471,6 @@<br> <br> static int load_module(void)<br> {<br>-   CHECK_PJSIP_MODULE_LOADED();<br>-<br>       /*<br>     * We only need one transport type name (ws) defined.  Firefox<br>         * and Chrome do not support anything other than secure websockets<br>@@ -490,10 +488,7 @@<br>              return AST_MODULE_LOAD_DECLINE;<br>       }<br> <br>- if (ast_sip_session_register_supplement(&websocket_supplement)) {<br>-                ast_sip_unregister_service(&websocket_module);<br>-           return AST_MODULE_LOAD_DECLINE;<br>-      }<br>+    ast_sip_session_register_supplement(&websocket_supplement);<br> <br>    if (ast_websocket_add_protocol("sip", websocket_cb)) {<br>              ast_sip_session_unregister_supplement(&websocket_supplement);<br>diff --git a/res/res_pjsip_xpidf_body_generator.c b/res/res_pjsip_xpidf_body_generator.c<br>index f7c84db..7395fd9 100644<br>--- a/res/res_pjsip_xpidf_body_generator.c<br>+++ b/res/res_pjsip_xpidf_body_generator.c<br>@@ -148,8 +148,6 @@<br> <br> static int load_module(void)<br> {<br>-        CHECK_PJSIP_PUBSUB_MODULE_LOADED();<br>-<br>        if (ast_sip_pubsub_register_body_generator(&xpidf_body_generator)) {<br>              goto fail;<br>    }<br>diff --git a/res/res_pktccops.c b/res/res_pktccops.c<br>index 3a12285..9beabfb 100644<br>--- a/res/res_pktccops.c<br>+++ b/res/res_pktccops.c<br>@@ -1472,9 +1472,6 @@<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 76e70c2..1d4826a 100644<br>--- a/res/res_smdi.c<br>+++ b/res/res_smdi.c<br>@@ -1405,9 +1405,6 @@<br>      ast_custom_function_register(&smdi_msg_retrieve_function);<br>        ast_custom_function_register(&smdi_msg_function);<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_stasis.c b/res/res_stasis.c<br>index a60ec5f..dcd7414 100644<br>--- a/res/res_stasis.c<br>+++ b/res/res_stasis.c<br>@@ -1302,8 +1302,6 @@<br> int stasis_app_exec(struct ast_channel *chan, const char *app_name, int argc,<br>                    char *argv[])<br> {<br>-        SCOPED_MODULE_USE(ast_module_info->self);<br>-<br>       RAII_VAR(struct stasis_app *, app, NULL, ao2_cleanup);<br>        RAII_VAR(struct stasis_app_control *, control, NULL, control_unlink);<br>         struct ast_bridge *bridge = NULL;<br>@@ -1654,11 +1652,6 @@<br> {<br>         AST_RWLIST_WRLOCK(&event_sources);<br>        AST_LIST_INSERT_TAIL(&event_sources, obj, next);<br>- /* only need to bump the module ref on non-core sources because the<br>-     core ones are [un]registered by this module. */<br>-   if (!stasis_app_is_core_event_source(obj)) {<br>-         ast_module_ref(ast_module_info->self);<br>-    }<br>     AST_RWLIST_UNLOCK(&event_sources);<br> }<br> <br>@@ -1670,9 +1663,6 @@<br>  AST_RWLIST_TRAVERSE_SAFE_BEGIN(&event_sources, source, next) {<br>            if (source == obj) {<br>                  AST_RWLIST_REMOVE_CURRENT(next);<br>-                     if (!stasis_app_is_core_event_source(obj)) {<br>-                         ast_module_unref(ast_module_info->self);<br>-                  }<br>                     break;<br>                }<br>     }<br>@@ -2034,16 +2024,6 @@<br>     ao2_ref(message, -1);<br> <br>      return STASIS_APP_USER_OK;<br>-}<br>-<br>-void stasis_app_ref(void)<br>-{<br>-    ast_module_ref(ast_module_info->self);<br>-}<br>-<br>-void stasis_app_unref(void)<br>-{<br>-   ast_module_unref(ast_module_info->self);<br> }<br> <br> static int unload_module(void)<br>diff --git a/res/res_stasis_mailbox.c b/res/res_stasis_mailbox.c<br>index 3d0e9db..3f6bede 100644<br>--- a/res/res_stasis_mailbox.c<br>+++ b/res/res_stasis_mailbox.c<br>@@ -143,17 +143,11 @@<br> <br> static int load_module(void)<br> {<br>-    /* Must be done first */<br>-     ast_mwi_external_ref();<br>-<br>    return AST_MODULE_LOAD_SUCCESS;<br> }<br> <br> static int unload_module(void)<br> {<br>-  /* Must be done last */<br>-      ast_mwi_external_unref();<br>-<br>  return 0;<br> }<br> <br>diff --git a/res/res_statsd.c b/res/res_statsd.c<br>index 221b359..8e647bc 100644<br>--- a/res/res_statsd.c<br>+++ b/res/res_statsd.c<br>@@ -353,9 +353,6 @@<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/stasis/app.c b/res/stasis/app.c<br>index 854e799..18ac7d6 100644<br>--- a/res/stasis/app.c<br>+++ b/res/stasis/app.c<br>@@ -1600,13 +1600,6 @@<br>       stasis_app_register_event_source(&endpoint_event_source);<br> }<br> <br>-int stasis_app_is_core_event_source(struct stasis_app_event_source *obj)<br>-{<br>-  return obj == &endpoint_event_source ||<br>-          obj == &bridge_event_source ||<br>-           obj == &channel_event_source;<br>-}<br>-<br> void stasis_app_unregister_event_sources(void)<br> {<br>         stasis_app_unregister_event_source(&endpoint_event_source);<br>diff --git a/rest-api-templates/res_ari_resource.c.mustache b/rest-api-templates/res_ari_resource.c.mustache<br>index c1f680f..e1894c9 100644<br>--- a/rest-api-templates/res_ari_resource.c.mustache<br>+++ b/rest-api-templates/res_ari_resource.c.mustache<br>@@ -266,7 +266,6 @@<br>         ast_ari_websocket_events_event_websocket_dtor();<br> {{/has_websocket}}<br> {{/apis}}<br>-    stasis_app_unref();<br>   return 0;<br> }<br> <br>@@ -274,43 +273,37 @@<br> {<br>   int res = 0;<br> <br>-      CHECK_ARI_MODULE_LOADED();<br>-<br> {{#apis}}<br> {{#operations}}<br> {{#has_websocket}}<br>-     /* This is scoped to not conflict with CHECK_ARI_MODULE_LOADED */<br>-    {<br>-            struct ast_websocket_protocol *protocol;<br>+     struct ast_websocket_protocol *protocol;<br> <br>-          if (ast_ari_websocket_{{c_name}}_{{c_nickname}}_init() == -1) {<br>-                      return AST_MODULE_LOAD_DECLINE;<br>-              }<br>+    if (ast_ari_websocket_{{c_name}}_{{c_nickname}}_init() == -1) {<br>+              return AST_MODULE_LOAD_DECLINE;<br>+      }<br> <br>-         {{full_name}}.ws_server = ast_websocket_server_create();<br>-             if (!{{full_name}}.ws_server) {<br>-                      ast_ari_websocket_events_event_websocket_dtor();<br>-                     return AST_MODULE_LOAD_DECLINE;<br>-              }<br>+    {{full_name}}.ws_server = ast_websocket_server_create();<br>+     if (!{{full_name}}.ws_server) {<br>+              ast_ari_websocket_events_event_websocket_dtor();<br>+             return AST_MODULE_LOAD_DECLINE;<br>+      }<br> <br>-         protocol = ast_websocket_sub_protocol_alloc("{{websocket_protocol}}");<br>-             if (!protocol) {<br>-                     ao2_ref({{full_name}}.ws_server, -1);<br>-                        {{full_name}}.ws_server = NULL;<br>-                      ast_ari_websocket_events_event_websocket_dtor();<br>-                     return AST_MODULE_LOAD_DECLINE;<br>-              }<br>-            protocol->session_attempted = ast_ari_{{c_name}}_{{c_nickname}}_ws_attempted_cb;<br>-          protocol->session_established = ast_ari_{{c_name}}_{{c_nickname}}_ws_established_cb;<br>+      protocol = ast_websocket_sub_protocol_alloc("{{websocket_protocol}}");<br>+     if (!protocol) {<br>+             ao2_ref({{full_name}}.ws_server, -1);<br>+                {{full_name}}.ws_server = NULL;<br>+              ast_ari_websocket_events_event_websocket_dtor();<br>+             return AST_MODULE_LOAD_DECLINE;<br>+      }<br>+    protocol->session_attempted = ast_ari_{{c_name}}_{{c_nickname}}_ws_attempted_cb;<br>+  protocol->session_established = ast_ari_{{c_name}}_{{c_nickname}}_ws_established_cb;<br> {{/has_websocket}}<br> {{#is_websocket}}<br>-             res |= ast_websocket_server_add_protocol2({{full_name}}.ws_server, protocol);<br>-        }<br>+    res |= ast_websocket_server_add_protocol2({{full_name}}.ws_server, protocol);<br> {{/is_websocket}}<br> {{/operations}}<br> {{/apis}}<br> <br>-   stasis_app_ref();<br>     res |= ast_ari_add_handler(&{{root_full_name}});<br>  if (res) {<br>            unload_module();<br>diff --git a/tests/test_res_pjsip_scheduler.c b/tests/test_res_pjsip_scheduler.c<br>index 47a7034..d0c2d90 100644<br>--- a/tests/test_res_pjsip_scheduler.c<br>+++ b/tests/test_res_pjsip_scheduler.c<br>@@ -376,8 +376,6 @@<br> <br> static int load_module(void)<br> {<br>- CHECK_PJSIP_MODULE_LOADED();<br>-<br>       AST_TEST_REGISTER(serialized_scheduler);<br>      AST_TEST_REGISTER(unserialized_scheduler);<br>    AST_TEST_REGISTER(scheduler_cleanup);<br>diff --git a/tests/test_res_stasis.c b/tests/test_res_stasis.c<br>index 077cc4c..2c7906a 100644<br>--- a/tests/test_res_stasis.c<br>+++ b/tests/test_res_stasis.c<br>@@ -179,13 +179,11 @@<br>     AST_TEST_UNREGISTER(app_invoke_dne);<br>  AST_TEST_UNREGISTER(app_invoke_one);<br>  AST_TEST_UNREGISTER(app_replaced);<br>-   stasis_app_unref();<br>   return 0;<br> }<br> <br> static int load_module(void)<br> {<br>-  stasis_app_ref();<br>     AST_TEST_REGISTER(app_replaced);<br>      AST_TEST_REGISTER(app_invoke_one);<br>    AST_TEST_REGISTER(app_invoke_dne);<br>diff --git a/tests/test_utils.c b/tests/test_utils.c<br>index 68a2857..f9746e2 100644<br>--- a/tests/test_utils.c<br>+++ b/tests/test_utils.c<br>@@ -391,7 +391,7 @@<br>      }<br> #endif<br> <br>-        ast_agi_unregister(ast_module_info->self, &noop_command);<br>+     ast_agi_unregister(&noop_command);<br>        return res;<br> }<br> <br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/7989">change 7989</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/7989"/><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: merged </div>
<div style="display:none"> Gerrit-Change-Id: I332a6e8383d4c72c8e89d988a184ab8320c4872e </div>
<div style="display:none"> Gerrit-Change-Number: 7989 </div>
<div style="display:none"> Gerrit-PatchSet: 6 </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>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>