summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES23
-rw-r--r--README.md2
-rw-r--r--apps/app_confbridge.c5
-rw-r--r--apps/app_meetme.c3
-rw-r--r--apps/app_mixmonitor.c7
-rw-r--r--apps/app_stack.c2
-rw-r--r--apps/app_stasis.c11
-rw-r--r--apps/app_statsd.c7
-rw-r--r--apps/app_voicemail.c12
-rw-r--r--apps/confbridge/conf_config_parser.c96
-rw-r--r--apps/confbridge/include/confbridge.h7
-rw-r--r--bridges/bridge_builtin_features.c7
-rw-r--r--bridges/bridge_softmix.c65
-rwxr-xr-xbuild_tools/list_valid_installed_externals3
-rw-r--r--channels/chan_pjsip.c30
-rw-r--r--configs/samples/confbridge.conf.sample80
-rw-r--r--configs/samples/modules.conf.sample7
-rwxr-xr-xconfigure48
-rw-r--r--configure.ac31
-rw-r--r--contrib/ast-db-manage/config/versions/d3e4284f8707_add_prune_on_boot_to_ps_subscription_.py33
-rwxr-xr-xcontrib/scripts/install_prereq47
-rw-r--r--doc/appdocsxml.xslt5
-rw-r--r--funcs/func_curl.c8
-rw-r--r--funcs/func_periodic_hook.c5
-rw-r--r--include/asterisk/agi.h6
-rw-r--r--include/asterisk/ari.h10
-rw-r--r--include/asterisk/autoconfig.h.in8
-rw-r--r--include/asterisk/bridge_technology.h6
-rw-r--r--include/asterisk/dsp.h38
-rw-r--r--include/asterisk/file.h5
-rw-r--r--include/asterisk/linkedlists.h2
-rw-r--r--include/asterisk/lock.h181
-rw-r--r--include/asterisk/pbx.h2
-rw-r--r--include/asterisk/res_mwi_external.h16
-rw-r--r--include/asterisk/res_pjproject.h22
-rw-r--r--include/asterisk/res_pjsip.h83
-rw-r--r--include/asterisk/res_pjsip_pubsub.h9
-rw-r--r--include/asterisk/res_pjsip_session.h21
-rw-r--r--include/asterisk/stasis_app.h30
-rw-r--r--main/Makefile1
-rw-r--r--main/asterisk.c45
-rw-r--r--main/dsp.c21
-rw-r--r--main/editline/el.h6
-rw-r--r--main/loader.c112
-rw-r--r--main/manager.c17
-rw-r--r--main/manager_channels.c21
-rw-r--r--main/pbx_variables.c245
-rw-r--r--main/utils.c12
-rw-r--r--res/ari/resource_bridges.c2
-rw-r--r--res/ari/resource_channels.c4
-rw-r--r--res/ari/resource_device_states.c1
-rw-r--r--res/ari/resource_events.c1
-rw-r--r--res/ari/resource_mailboxes.c1
-rw-r--r--res/ari/resource_playbacks.c1
-rw-r--r--res/ari/resource_recordings.c1
-rw-r--r--res/res_agi.c19
-rw-r--r--res/res_ari.c2
-rw-r--r--res/res_ari_applications.c4
-rw-r--r--res/res_ari_asterisk.c4
-rw-r--r--res/res_ari_bridges.c8
-rw-r--r--res/res_ari_channels.c10
-rw-r--r--res/res_ari_device_states.c7
-rw-r--r--res/res_ari_endpoints.c4
-rw-r--r--res/res_ari_events.c46
-rw-r--r--res/res_ari_mailboxes.c7
-rw-r--r--res/res_ari_playbacks.c7
-rw-r--r--res/res_ari_recordings.c7
-rw-r--r--res/res_ari_sounds.c4
-rw-r--r--res/res_config_curl.c15
-rw-r--r--res/res_crypto.c3
-rw-r--r--res/res_curl.c24
-rw-r--r--res/res_fax.c2
-rw-r--r--res/res_hep_pjsip.c6
-rw-r--r--res/res_hep_rtcp.c4
-rw-r--r--res/res_http_media_cache.c1
-rw-r--r--res/res_http_websocket.c33
-rw-r--r--res/res_monitor.c4
-rw-r--r--res/res_mwi_external.c10
-rw-r--r--res/res_mwi_external_ami.c5
-rw-r--r--res/res_pjproject.c10
-rw-r--r--res/res_pjsip.c164
-rw-r--r--res/res_pjsip/config_auth.c4
-rw-r--r--res/res_pjsip/config_transport.c5
-rw-r--r--res/res_pjsip/include/res_pjsip_private.h62
-rw-r--r--res/res_pjsip/location.c4
-rw-r--r--res/res_pjsip/pjsip_distributor.c12
-rw-r--r--res/res_pjsip/pjsip_global_headers.c4
-rw-r--r--res/res_pjsip/pjsip_message_filter.c16
-rw-r--r--res/res_pjsip/pjsip_options.c4
-rw-r--r--res/res_pjsip/pjsip_session.c25
-rw-r--r--res/res_pjsip/pjsip_transport_events.c83
-rw-r--r--res/res_pjsip_acl.c2
-rw-r--r--res/res_pjsip_authenticator_digest.c2
-rw-r--r--res/res_pjsip_caller_id.c2
-rw-r--r--res/res_pjsip_dialog_info_body_generator.c2
-rw-r--r--res/res_pjsip_diversion.c4
-rw-r--r--res/res_pjsip_dlg_options.c5
-rw-r--r--res/res_pjsip_dtmf_info.c4
-rw-r--r--res/res_pjsip_empty_info.c4
-rw-r--r--res/res_pjsip_endpoint_identifier_anonymous.c2
-rw-r--r--res/res_pjsip_endpoint_identifier_ip.c2
-rw-r--r--res/res_pjsip_endpoint_identifier_user.c2
-rw-r--r--res/res_pjsip_exten_state.c7
-rw-r--r--res/res_pjsip_header_funcs.c2
-rw-r--r--res/res_pjsip_history.c2
-rw-r--r--res/res_pjsip_logger.c2
-rw-r--r--res/res_pjsip_messaging.c4
-rw-r--r--res/res_pjsip_mwi.c4
-rw-r--r--res/res_pjsip_mwi_body_generator.c2
-rw-r--r--res/res_pjsip_nat.c10
-rw-r--r--res/res_pjsip_notify.c2
-rw-r--r--res/res_pjsip_one_touch_record_info.c9
-rw-r--r--res/res_pjsip_outbound_authenticator_digest.c2
-rw-r--r--res/res_pjsip_outbound_publish.c4
-rw-r--r--res/res_pjsip_outbound_registration.c16
-rw-r--r--res/res_pjsip_path.c14
-rw-r--r--res/res_pjsip_phoneprov_provider.c2
-rw-r--r--res/res_pjsip_pidf_body_generator.c2
-rw-r--r--res/res_pjsip_pidf_digium_body_supplement.c2
-rw-r--r--res/res_pjsip_pidf_eyebeam_body_supplement.c2
-rw-r--r--res/res_pjsip_publish_asterisk.c2
-rw-r--r--res/res_pjsip_pubsub.c77
-rw-r--r--res/res_pjsip_refer.c2
-rw-r--r--res/res_pjsip_registrar.c177
-rw-r--r--res/res_pjsip_registrar_expire.c154
-rw-r--r--res/res_pjsip_rfc3326.c4
-rw-r--r--res/res_pjsip_sdp_rtp.c2
-rw-r--r--res/res_pjsip_send_to_voicemail.c7
-rw-r--r--res/res_pjsip_session.c45
-rw-r--r--res/res_pjsip_sips_contact.c2
-rw-r--r--res/res_pjsip_t38.c7
-rw-r--r--res/res_pjsip_transport_management.c2
-rw-r--r--res/res_pjsip_transport_websocket.c7
-rw-r--r--res/res_pjsip_xpidf_body_generator.c2
-rw-r--r--res/res_pktccops.c3
-rw-r--r--res/res_smdi.c3
-rw-r--r--res/res_stasis.c20
-rw-r--r--res/res_stasis_mailbox.c6
-rw-r--r--res/res_statsd.c9
-rw-r--r--res/stasis/app.c7
-rw-r--r--rest-api-templates/res_ari_resource.c.mustache50
-rw-r--r--rest-api-templates/swagger_model.py1
-rw-r--r--rest-api/api-docs/bridges.json4
-rw-r--r--rest-api/api-docs/channels.json6
-rw-r--r--rest-api/api-docs/deviceStates.json3
-rw-r--r--rest-api/api-docs/events.json3
-rw-r--r--rest-api/api-docs/mailboxes.json3
-rw-r--r--rest-api/api-docs/playbacks.json3
-rw-r--r--rest-api/api-docs/recordings.json3
-rw-r--r--sounds/Makefile4
-rw-r--r--tests/test_res_pjsip_scheduler.c2
-rw-r--r--tests/test_res_stasis.c2
-rw-r--r--tests/test_utils.c9
-rw-r--r--tests/test_websocket_client.c7
-rw-r--r--utils/check_expr.c7
155 files changed, 1345 insertions, 1522 deletions
diff --git a/CHANGES b/CHANGES
index 304bba60a..b9d803277 100644
--- a/CHANGES
+++ b/CHANGES
@@ -51,6 +51,14 @@ res_pjsip
* A new AMI action, PJSIPShowAuths, has been added which displays information
about all configured PJSIP Auths.
+ * A new AMI action, PJSIPShowContacts, has been added which displays information
+ about all configured PJSIP Contacts.
+
+res_pjsip_registrar_expire
+------------------
+ * The res_pjsip_registrar_expire module has been removed. The functionality has
+ been moved into res_pjsip_registrar.
+
cdr_syslog
------------------
* The cdr_syslog module is now deprecated and by default it is no longer
@@ -78,6 +86,10 @@ res_pjsip
identifier method split into the "ip" and "header" endpoint identifier
methods.
+ * The pjsip_transport_event feature introduced in 15.1.0 has been refactored.
+ Any external modules that may have used that feature (highly unlikey) will
+ need to be changed as the API has been altered slightly.
+
res_pjsip_endpoint_identifier_ip
------------------
* The endpoint identifier "ip" method previously recognized endpoints either
@@ -92,6 +104,17 @@ res_pjsip_endpoint_identifier_ip
you can now predict which endpoint is matched when a request comes in that
matches both.
+res_pjsip_pubsub
+------------------
+ * In an earlier release, inbound registrations on a reliable transport
+ were pruned on Asterisk restart since the TCP connection would have
+ been torn down and become unusable when Asterisk stopped. This same
+ process is now also applied to inbound subscriptions. Since this
+ required the addition of a new column to the ps_subscription_persistence
+ realtime table, users who store their subscriptions in a database will
+ need to run the "alembic upgrade head" process to add the column to
+ the schema.
+
------------------------------------------------------------------------------
--- Functionality changes from Asterisk 15.1.0 to Asterisk 15.2.0 ------------
------------------------------------------------------------------------------
diff --git a/README.md b/README.md
index 153c4f3e4..10158b374 100644
--- a/README.md
+++ b/README.md
@@ -69,7 +69,7 @@ list of new features in this version of Asterisk, see the [CHANGES] file.
Ensure that your system contains a compatible compiler and development
libraries. Asterisk requires either the GNU Compiler Collection (GCC) version
-3.0 or higher, or a compiler that supports the C99 specification and some of
+4.1 or higher, or a compiler that supports the C99 specification and some of
the gcc language extensions. In addition, your system needs to have the C
library headers available, and the headers and libraries for ncurses.
diff --git a/apps/app_confbridge.c b/apps/app_confbridge.c
index f972e38b9..7e6f94c34 100644
--- a/apps/app_confbridge.c
+++ b/apps/app_confbridge.c
@@ -2386,11 +2386,11 @@ static int confbridge_exec(struct ast_channel *chan, const char *data)
user.tech_args.drop_silence = 1;
}
- if (ast_test_flag(&user.u_profile, USER_OPT_JITTERBUFFER) && ast_module_check("func_jitterbuffer.so")) {
+ if (ast_test_flag(&user.u_profile, USER_OPT_JITTERBUFFER)) {
ast_func_write(chan, "JITTERBUFFER(adaptive)", "default");
}
- if (ast_test_flag(&user.u_profile, USER_OPT_DENOISE) && ast_module_check("codec_speex.so")) {
+ if (ast_test_flag(&user.u_profile, USER_OPT_DENOISE)) {
ast_func_write(chan, "DENOISE(rx)", "on");
}
@@ -4088,4 +4088,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Conference Bridge App
.unload = unload_module,
.reload = reload,
.load_pri = AST_MODPRI_DEVSTATE_PROVIDER,
+ .optional_modules = "codec_speex,func_jitterbuffer",
);
diff --git a/apps/app_meetme.c b/apps/app_meetme.c
index 634eac820..657aaa7b7 100644
--- a/apps/app_meetme.c
+++ b/apps/app_meetme.c
@@ -3588,7 +3588,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, struc
}
/* Reduce background noise from each participant */
- if (!ast_test_flag64(confflags, CONFFLAG_DONT_DENOISE) && ast_module_check("func_speex.so")) {
+ if (!ast_test_flag64(confflags, CONFFLAG_DONT_DENOISE)) {
ast_func_write(chan, "DENOISE(rx)", "on");
}
@@ -8085,4 +8085,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "MeetMe conference bri
.unload = unload_module,
.reload = reload,
.load_pri = AST_MODPRI_DEVSTATE_PROVIDER,
+ .optional_modules = "func_speex",
);
diff --git a/apps/app_mixmonitor.c b/apps/app_mixmonitor.c
index bb47cfc34..af2949209 100644
--- a/apps/app_mixmonitor.c
+++ b/apps/app_mixmonitor.c
@@ -1556,4 +1556,9 @@ static int load_module(void)
return res;
}
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Mixed Audio Monitoring Application");
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Mixed Audio Monitoring Application",
+ .support_level = AST_MODULE_SUPPORT_CORE,
+ .load = load_module,
+ .unload = unload_module,
+ .optional_modules = "func_periodic_hook",
+);
diff --git a/apps/app_stack.c b/apps/app_stack.c
index 1f98378c9..4560865ab 100644
--- a/apps/app_stack.c
+++ b/apps/app_stack.c
@@ -1278,7 +1278,7 @@ static int unload_module(void)
{
ast_install_stack_functions(NULL);
- ast_agi_unregister(ast_module_info->self, &gosub_agi_command);
+ ast_agi_unregister(&gosub_agi_command);
ast_unregister_application(app_return);
ast_unregister_application(app_pop);
diff --git a/apps/app_stasis.c b/apps/app_stasis.c
index 8d09349b9..b98c2b446 100644
--- a/apps/app_stasis.c
+++ b/apps/app_stasis.c
@@ -125,19 +125,12 @@ static int app_exec(struct ast_channel *chan, const char *data)
static int load_module(void)
{
- int r = 0;
-
- stasis_app_ref();
- r |= ast_register_application_xml(stasis, app_exec);
- return r;
+ return ast_register_application_xml(stasis, app_exec);
}
static int unload_module(void)
{
- int r = 0;
- r |= ast_unregister_application(stasis);
- stasis_app_unref();
- return r;
+ return ast_unregister_application(stasis);
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Stasis dialplan application",
diff --git a/apps/app_statsd.c b/apps/app_statsd.c
index 54f9511a8..a4ca233ea 100644
--- a/apps/app_statsd.c
+++ b/apps/app_statsd.c
@@ -420,4 +420,9 @@ static int load_module(void)
return ast_register_application_xml(app, statsd_exec);
}
-AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "StatsD Dialplan Application");
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "StatsD Dialplan Application",
+ .support_level = AST_MODULE_SUPPORT_EXTENDED,
+ .load = load_module,
+ .unload = unload_module,
+ .requires = "res_statsd",
+);
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 4853a53f9..72e3e59c1 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -3499,7 +3499,7 @@ static struct vm_state *get_vm_state_by_imapuser(const char *user, int interacti
if (interactive) {
struct vm_state *vms;
pthread_once(&ts_vmstate.once, ts_vmstate.key_init);
- if ((vms = pthread_getspecific(ts_vmstate.key)) && vms->imapuser && !strcmp(vms->imapuser, user)) {
+ if ((vms = pthread_getspecific(ts_vmstate.key)) && !strcmp(vms->imapuser, user)) {
return vms;
}
}
@@ -3513,10 +3513,6 @@ static struct vm_state *get_vm_state_by_imapuser(const char *user, int interacti
if (vlist->vms->imapversion != imapversion) {
continue;
}
- if (!vlist->vms->imapuser) {
- ast_debug(3, "error: imapuser is NULL for %s\n", user);
- continue;
- }
if (!strcmp(vlist->vms->imapuser, user) && (interactive == 2 || vlist->vms->interactive == interactive)) {
AST_LIST_UNLOCK(&vmstates);
@@ -3539,7 +3535,7 @@ static struct vm_state *get_vm_state_by_mailbox(const char *mailbox, const char
if (interactive) {
struct vm_state *vms;
pthread_once(&ts_vmstate.once, ts_vmstate.key_init);
- if ((vms = pthread_getspecific(ts_vmstate.key)) && vms->username && vms->context &&
+ if ((vms = pthread_getspecific(ts_vmstate.key)) &&
!strcmp(vms->username,mailbox) && !strcmp(vms->context, local_context)) {
return vms;
}
@@ -3554,10 +3550,6 @@ static struct vm_state *get_vm_state_by_mailbox(const char *mailbox, const char
if (vlist->vms->imapversion != imapversion) {
continue;
}
- if (!vlist->vms->username || !vlist->vms->context) {
- ast_debug(3, "error: username is NULL for %s\n", mailbox);
- continue;
- }
ast_debug(3, "comparing mailbox %s@%s (i=%d) to vmstate mailbox %s@%s (i=%d)\n", mailbox, local_context, interactive, vlist->vms->username, vlist->vms->context, vlist->vms->interactive);
diff --git a/apps/confbridge/conf_config_parser.c b/apps/confbridge/conf_config_parser.c
index 99eea0a27..71da80206 100644
--- a/apps/confbridge/conf_config_parser.c
+++ b/apps/confbridge/conf_config_parser.c
@@ -144,72 +144,66 @@
</para></description>
</configOption>
<configOption name="dsp_silence_threshold">
- <synopsis>The number of milliseconds of detected silence necessary to trigger silence detection</synopsis>
- <description><para>
- The time in milliseconds of sound falling within the what
- the dsp has established as baseline silence before a user
- is considered be silent. This value affects several
- operations and should not be changed unless the impact
- on call quality is fully understood.</para>
- <para>What this value affects internally:</para>
- <para>
- 1. When talk detection AMI events are enabled, this value
+ <synopsis>The number of milliseconds of silence necessary to declare talking stopped.</synopsis>
+ <description>
+ <para>The time in milliseconds of sound falling below the
+ <replaceable>dsp_talking_threshold</replaceable> option when
+ a user is considered to stop talking. This value affects several
+ operations and should not be changed unless the impact on call
+ quality is fully understood.
+ </para>
+ <para>What this value affects internally:
+ </para>
+ <para>1. When talk detection AMI events are enabled, this value
determines when the user has stopped talking after a
period of talking. If this value is set too low
AMI events indicating the user has stopped talking
may get falsely sent out when the user briefly pauses
during mid sentence.
- </para>
- <para>
- 2. The <replaceable>drop_silence</replaceable> option depends on this value to
- determine when the user's audio should begin to be
- dropped from the conference bridge after the user
+ </para>
+ <para>2. The <replaceable>drop_silence</replaceable> option
+ depends on this value to determine when the user's audio should
+ begin to be dropped from the conference bridge after the user
stops talking. If this value is set too low the user's
- audio stream may sound choppy to the other participants.
- This is caused by the user transitioning constantly from
- silence to talking during mid sentence.
- </para>
- <para>
- The best way to approach this option is to set it slightly above
- the maximum amount of ms of silence a user may generate during
- natural speech.
- </para>
- <para>By default this value is 2500ms. Valid values are 1 through 2^31.</para>
+ audio stream may sound choppy to the other participants. This
+ is caused by the user transitioning constantly from silence to
+ talking during mid sentence.
+ </para>
+ <para>The best way to approach this option is to set it slightly
+ above the maximum amount of milliseconds of silence a user may
+ generate during natural speech.
+ </para>
+ <para>Valid values are 1 through 2^31.</para>
</description>
</configOption>
<configOption name="dsp_talking_threshold">
- <synopsis>The number of milliseconds of detected non-silence necessary to triger talk detection</synopsis>
- <description><para>
- The time in milliseconds of sound above what the dsp has
- established as base line silence for a user before a user
- is considered to be talking. This value affects several
- operations and should not be changed unless the impact on
- call quality is fully understood.</para>
- <para>
- What this value affects internally:
+ <synopsis>Average magnitude threshold to determine talking.</synopsis>
+ <description>
+ <para>The minimum average magnitude per sample in a frame
+ for the DSP to consider talking/noise present. A value below
+ this level is considered silence. This value affects several
+ operations and should not be changed unless the impact on call
+ quality is fully understood.
+ </para>
+ <para>What this value affects internally:
</para>
- <para>
- 1. Audio is only mixed out of a user's incoming audio stream
- if talking is detected. If this value is set too
- loose the user will hear themselves briefly each
- time they begin talking until the dsp has time to
- establish that they are in fact talking.
+ <para>1. Audio is only mixed out of a user's incoming audio
+ stream if talking is detected. If this value is set too
+ high the user will hear himself talking.
</para>
- <para>
- 2. When talk detection AMI events are enabled, this value
+ <para>2. When talk detection AMI events are enabled, this value
determines when talking has begun which results in
- an AMI event to fire. If this value is set too tight
+ an AMI event to fire. If this value is set too low
AMI events may be falsely triggered by variants in
room noise.
</para>
- <para>
- 3. The <replaceable>drop_silence</replaceable> option depends on this value to determine
- when the user's audio should be mixed into the bridge
- after periods of silence. If this value is too loose
- the beginning of a user's speech will get cut off as they
- transition from silence to talking.
+ <para>3. The <replaceable>drop_silence</replaceable> option
+ depends on this value to determine when the user's audio should
+ be mixed into the bridge after periods of silence. If this value
+ is too high the user's speech will get discarded as they will
+ be considered silent.
</para>
- <para>By default this value is 160 ms. Valid values are 1 through 2^31</para>
+ <para>Valid values are 1 through 2^15.</para>
</description>
</configOption>
<configOption name="jitterbuffer">
@@ -1479,7 +1473,7 @@ static char *handle_cli_confbridge_show_user_profile(struct ast_cli_entry *e, in
"enabled" : "disabled");
ast_cli(a->fd,"Silence Threshold: %ums\n",
u_profile.silence_threshold);
- ast_cli(a->fd,"Talking Threshold: %ums\n",
+ ast_cli(a->fd,"Talking Threshold: %u\n",
u_profile.talking_threshold);
ast_cli(a->fd,"Denoise: %s\n",
u_profile.flags & USER_OPT_DENOISE ?
diff --git a/apps/confbridge/include/confbridge.h b/apps/confbridge/include/confbridge.h
index 162ff224c..044ab4003 100644
--- a/apps/confbridge/include/confbridge.h
+++ b/apps/confbridge/include/confbridge.h
@@ -41,7 +41,10 @@
#define DEFAULT_BRIDGE_PROFILE "default_bridge"
#define DEFAULT_MENU_PROFILE "default_menu"
+/*! Default minimum average magnitude threshold to determine talking by the DSP. */
#define DEFAULT_TALKING_THRESHOLD 160
+
+/*! Default time in ms of silence necessary to declare talking stopped by the bridge. */
#define DEFAULT_SILENCE_THRESHOLD 2500
enum user_profile_flags {
@@ -140,9 +143,9 @@ struct user_profile {
char announcement[PATH_MAX];
unsigned int flags;
unsigned int announce_user_count_all_after;
- /*! The time in ms of talking before a user is considered to be talking by the dsp. */
+ /*! Minimum average magnitude threshold to determine talking by the DSP. */
unsigned int talking_threshold;
- /*! The time in ms of silence before a user is considered to be silent by the dsp. */
+ /*! Time in ms of silence necessary to declare talking stopped by the bridge. */
unsigned int silence_threshold;
/*! The time in ms the user may stay in the confbridge */
unsigned int timeout;
diff --git a/bridges/bridge_builtin_features.c b/bridges/bridge_builtin_features.c
index e6cacbf7e..e9efb916c 100644
--- a/bridges/bridge_builtin_features.c
+++ b/bridges/bridge_builtin_features.c
@@ -519,4 +519,9 @@ static int load_module(void)
return AST_MODULE_LOAD_SUCCESS;
}
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Built in bridging features");
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Built in bridging features",
+ .support_level = AST_MODULE_SUPPORT_CORE,
+ .load = load_module,
+ .unload = unload_module,
+ .optional_modules = "res_monitor",
+);
diff --git a/bridges/bridge_softmix.c b/bridges/bridge_softmix.c
index 1ff92ad91..9986d9c73 100644
--- a/bridges/bridge_softmix.c
+++ b/bridges/bridge_softmix.c
@@ -53,9 +53,16 @@
/*! \brief Number of mixing iterations to perform between gathering statistics. */
#define SOFTMIX_STAT_INTERVAL 100
-/* This is the threshold in ms at which a channel's own audio will stop getting
- * mixed out its own write audio stream because it is not talking. */
+/*!
+ * \brief Default time in ms of silence necessary to declare talking stopped by the bridge.
+ *
+ * \details
+ * This is the time at which a channel's own audio will stop getting
+ * mixed out of its own write audio stream because it is no longer talking.
+ */
#define DEFAULT_SOFTMIX_SILENCE_THRESHOLD 2500
+
+/*! Default minimum average magnitude threshold to determine talking by the DSP. */
#define DEFAULT_SOFTMIX_TALKING_THRESHOLD 160
#define SOFTBRIDGE_VIDEO_DEST_PREFIX "softbridge_dest"
@@ -860,12 +867,17 @@ static void softmix_bridge_write_voice(struct ast_bridge *bridge, struct ast_bri
{
struct softmix_channel *sc = bridge_channel->tech_pvt;
struct softmix_bridge_data *softmix_data = bridge->tech_pvt;
+ int silent = 0;
int totalsilence = 0;
int cur_energy = 0;
int silence_threshold = bridge_channel->tech_args.silence_threshold ?
bridge_channel->tech_args.silence_threshold :
DEFAULT_SOFTMIX_SILENCE_THRESHOLD;
- char update_talking = -1; /* if this is set to 0 or 1, tell the bridge that the channel has started or stopped talking. */
+ /*
+ * If update_talking is set to 0 or 1, tell the bridge that the channel
+ * has started or stopped talking.
+ */
+ char update_talking = -1;
/* Write the frame into the conference */
ast_mutex_lock(&sc->lock);
@@ -893,7 +905,7 @@ static void softmix_bridge_write_voice(struct ast_bridge *bridge, struct ast_bri
/* The channel will be leaving soon if there is no dsp. */
if (sc->dsp) {
- ast_dsp_silence_with_energy(sc->dsp, frame, &totalsilence, &cur_energy);
+ silent = ast_dsp_silence_with_energy(sc->dsp, frame, &totalsilence, &cur_energy);
}
if (bridge->softmix.video_mode.mode == AST_BRIDGE_VIDEO_MODE_TALKER_SRC) {
@@ -910,15 +922,16 @@ static void softmix_bridge_write_voice(struct ast_bridge *bridge, struct ast_bri
}
if (totalsilence < silence_threshold) {
- if (!sc->talking) {
+ if (!sc->talking && !silent) {
+ /* Tell the write process we have audio to be mixed out */
+ sc->talking = 1;
update_talking = 1;
}
- sc->talking = 1; /* tell the write process we have audio to be mixed out */
} else {
if (sc->talking) {
+ sc->talking = 0;
update_talking = 0;
}
- sc->talking = 0;
}
/* Before adding audio in, make sure we haven't fallen behind. If audio has fallen
@@ -928,9 +941,8 @@ static void softmix_bridge_write_voice(struct ast_bridge *bridge, struct ast_bri
ast_slinfactory_flush(&sc->factory);
}
- /* If a frame was provided add it to the smoother, unless drop silence is enabled and this frame
- * is not determined to be talking. */
- if (!(bridge_channel->tech_args.drop_silence && !sc->talking)) {
+ if (sc->talking || !bridge_channel->tech_args.drop_silence) {
+ /* Add frame to the smoother for mixing with other channels. */
ast_slinfactory_feed(&sc->factory, frame);
}
@@ -942,6 +954,38 @@ static void softmix_bridge_write_voice(struct ast_bridge *bridge, struct ast_bri
}
}
+/*!
+ * \internal
+ * \brief Check for voice status updates.
+ * \since 13.20.0
+ *
+ * \param bridge Which bridge we are in
+ * \param bridge_channel Which channel we are checking
+ *
+ * \return Nothing
+ */
+static void softmix_bridge_check_voice(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
+{
+ struct softmix_channel *sc = bridge_channel->tech_pvt;
+
+ if (sc->talking
+ && bridge_channel->features->mute) {
+ /*
+ * We were muted while we were talking.
+ *
+ * Immediately stop contributing to mixing
+ * and report no longer talking.
+ */
+ ast_mutex_lock(&sc->lock);
+ ast_slinfactory_flush(&sc->factory);
+ sc->talking = 0;
+ ast_mutex_unlock(&sc->lock);
+
+ /* Notify that we are no longer talking. */
+ ast_bridge_channel_notify_talking(bridge_channel, 0);
+ }
+}
+
static int remove_all_original_streams(struct ast_stream_topology *dest,
const struct ast_stream_topology *source,
const struct ast_stream_topology *original)
@@ -1119,6 +1163,7 @@ static int softmix_bridge_write(struct ast_bridge *bridge, struct ast_bridge_cha
switch (frame->frametype) {
case AST_FRAME_NULL:
/* "Accept" the frame and discard it. */
+ softmix_bridge_check_voice(bridge, bridge_channel);
break;
case AST_FRAME_DTMF_BEGIN:
case AST_FRAME_DTMF_END:
diff --git a/build_tools/list_valid_installed_externals b/build_tools/list_valid_installed_externals
index c37102208..862447a64 100755
--- a/build_tools/list_valid_installed_externals
+++ b/build_tools/list_valid_installed_externals
@@ -19,10 +19,7 @@ EOF
XMLSTARLET=`getvar XMLSTARLET`
ASTMODDIR=`getvar ASTMODDIR`
-cache_dir=`getvar EXTERNALS_CACHE_DIR`
-DOWNLOAD_TO_STDOUT=`getvar DOWNLOAD_TO_STDOUT`
HOST_CPU=`getvar HOST_CPU`
-INSTALL=`getvar INSTALL`
tmpdir=$(mktemp -d)
if [[ -z "${tmpdir}" ]] ; then
diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c
index 68da4a1bb..2c111feeb 100644
--- a/channels/chan_pjsip.c
+++ b/channels/chan_pjsip.c
@@ -2981,8 +2981,6 @@ static int load_module(void)
{
struct ao2_container *endpoints;
- CHECK_PJSIP_SESSION_MODULE_LOADED();
-
if (!(chan_pjsip_tech.capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
return AST_MODULE_LOAD_DECLINE;
}
@@ -3016,10 +3014,7 @@ static int load_module(void)
goto end;
}
- if (ast_sip_session_register_supplement(&chan_pjsip_supplement)) {
- ast_log(LOG_ERROR, "Unable to register PJSIP supplement\n");
- goto end;
- }
+ ast_sip_session_register_supplement(&chan_pjsip_supplement);
if (!(pjsip_uids_onhold = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_RWLOCK,
AO2_CONTAINER_ALLOC_OPT_DUPS_REJECT, 37, uid_hold_hash_fn,
@@ -3028,26 +3023,9 @@ static int load_module(void)
goto end;
}
- if (ast_sip_session_register_supplement(&call_pickup_supplement)) {
- ast_log(LOG_ERROR, "Unable to register PJSIP call pickup supplement\n");
- ast_sip_session_unregister_supplement(&chan_pjsip_supplement);
- goto end;
- }
-
- if (ast_sip_session_register_supplement(&pbx_start_supplement)) {
- ast_log(LOG_ERROR, "Unable to register PJSIP pbx start supplement\n");
- ast_sip_session_unregister_supplement(&chan_pjsip_supplement);
- ast_sip_session_unregister_supplement(&call_pickup_supplement);
- goto end;
- }
-
- if (ast_sip_session_register_supplement(&chan_pjsip_ack_supplement)) {
- ast_log(LOG_ERROR, "Unable to register PJSIP ACK supplement\n");
- ast_sip_session_unregister_supplement(&pbx_start_supplement);
- ast_sip_session_unregister_supplement(&chan_pjsip_supplement);
- ast_sip_session_unregister_supplement(&call_pickup_supplement);
- goto end;
- }
+ ast_sip_session_register_supplement(&call_pickup_supplement);
+ ast_sip_session_register_supplement(&pbx_start_supplement);
+ ast_sip_session_register_supplement(&chan_pjsip_ack_supplement);
if (pjsip_channel_cli_register()) {
ast_log(LOG_ERROR, "Unable to register PJSIP Channel CLI\n");
diff --git a/configs/samples/confbridge.conf.sample b/configs/samples/confbridge.conf.sample
index c8f30bcc3..e2d8a620d 100644
--- a/configs/samples/confbridge.conf.sample
+++ b/configs/samples/confbridge.conf.sample
@@ -49,59 +49,67 @@ type=user
; noise from the conference. Highly recommended for large conferences
; due to its performance enhancements.
-;dsp_talking_threshold=128 ; The time in milliseconds of sound above what the dsp has
- ; established as base line silence for a user before a user
- ; is considered to be talking. This value affects several
+;dsp_talking_threshold=128 ; Average magnitude threshold to determine talking.
+ ;
+ ; The minimum average magnitude per sample in a frame for the
+ ; DSP to consider talking/noise present. A value below this
+ ; level is considered silence. This value affects several
; operations and should not be changed unless the impact on
; call quality is fully understood.
;
; What this value affects internally:
;
- ; 1. Audio is only mixed out of a user's incoming audio stream
- ; if talking is detected. If this value is set too
- ; loose the user will hear themselves briefly each
- ; time they begin talking until the dsp has time to
- ; establish that they are in fact talking.
+ ; 1. Audio is only mixed out of a user's incoming audio
+ ; stream if talking is detected. If this value is set too
+ ; high the user will hear himself talking.
+ ;
; 2. When talk detection AMI events are enabled, this value
- ; determines when talking has begun which results in
- ; an AMI event to fire. If this value is set too tight
- ; AMI events may be falsely triggered by variants in
- ; room noise.
- ; 3. The drop_silence option depends on this value to determine
- ; when the user's audio should be mixed into the bridge
- ; after periods of silence. If this value is too loose
- ; the beginning of a user's speech will get cut off as they
- ; transition from silence to talking.
+ ; determines when talking has begun which results in an
+ ; AMI event to fire. If this value is set too low AMI
+ ; events may be falsely triggered by variants in room
+ ; noise.
+ ;
+ ; 3. The 'drop_silence' option depends on this value to
+ ; determine when the user's audio should be mixed into the
+ ; bridge after periods of silence. If this value is too
+ ; high the user's speech will get discarded as they will
+ ; be considered silent.
;
- ; By default this value is 160 ms. Valid values are 1 through 2^31
+ ; Valid values are 1 through 2^15.
+ ; By default this value is 160.
-;dsp_silence_threshold=2000 ; The time in milliseconds of sound falling within the what
- ; the dsp has established as baseline silence before a user
- ; is considered be silent. This value affects several
- ; operations and should not be changed unless the impact
- ; on call quality is fully understood.
+;dsp_silence_threshold=2000 ; The number of milliseconds of silence necessary to declare
+ ; talking stopped.
+ ;
+ ; The time in milliseconds of sound falling below the
+ ; 'dsp_talking_threshold' option when a user is considered to
+ ; stop talking. This value affects several operations and
+ ; should not be changed unless the impact on call quality is
+ ; fully understood.
;
; What this value affects internally:
;
; 1. When talk detection AMI events are enabled, this value
; determines when the user has stopped talking after a
- ; period of talking. If this value is set too low
- ; AMI events indicating the user has stopped talking
- ; may get falsely sent out when the user briefly pauses
- ; during mid sentence.
- ; 2. The drop_silence option depends on this value to
+ ; period of talking. If this value is set too low AMI
+ ; events indicating the user has stopped talking may get
+ ; falsely sent out when the user briefly pauses during mid
+ ; sentence.
+ ;
+ ; 2. The 'drop_silence' option depends on this value to
; determine when the user's audio should begin to be
- ; dropped from the conference bridge after the user
- ; stops talking. If this value is set too low the user's
- ; audio stream may sound choppy to the other participants.
- ; This is caused by the user transitioning constantly from
+ ; dropped from the conference bridge after the user stops
+ ; talking. If this value is set too low the user's audio
+ ; stream may sound choppy to the other participants. This
+ ; is caused by the user transitioning constantly from
; silence to talking during mid sentence.
;
- ; The best way to approach this option is to set it slightly above
- ; the maximum amount of ms of silence a user may generate during
- ; natural speech.
+ ; The best way to approach this option is to set it slightly
+ ; above the maximum amount of milliseconds of silence a user
+ ; may generate during natural speech.
;
- ; By default this value is 2500ms. Valid values are 1 through 2^31
+ ; Valid values are 1 through 2^31.
+ ; By default this value is 2500ms.
;talk_detection_events=yes ; This option sets whether or not notifications of when a user
; begins and ends talking should be sent out as events over AMI.
diff --git a/configs/samples/modules.conf.sample b/configs/samples/modules.conf.sample
index 38e33e1f4..431a0a8cf 100644
--- a/configs/samples/modules.conf.sample
+++ b/configs/samples/modules.conf.sample
@@ -29,12 +29,7 @@ autoload=yes
; If you want you can combine with preload
; preload-require = res_odbc.so
;
-; If you want, load the GTK console right away.
-;
-noload => pbx_gtkconsole.so
-;load => pbx_gtkconsole.so
-;
-load => res_musiconhold.so
+;load => res_musiconhold.so
;
; Load one of: chan_oss, alsa, or console (portaudio).
; By default, load chan_oss only (automatically).
diff --git a/configure b/configure
index 867643ecb..f6e83d9eb 100755
--- a/configure
+++ b/configure
@@ -17893,8 +17893,8 @@ fi
done
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for compiler atomic operations" >&5
-$as_echo_n "checking for compiler atomic operations... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for compiler sync operations" >&5
+$as_echo_n "checking for compiler sync operations... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -17909,6 +17909,7 @@ _ACEOF
if ac_fn_c_try_link "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
+ax_cv_have_gcc_atomics=1
$as_echo "#define HAVE_GCC_ATOMICS 1" >>confdefs.h
@@ -17920,6 +17921,38 @@ fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for compiler atomic operations" >&5
+$as_echo_n "checking for compiler atomic operations... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+int foo1; int foo2 = __atomic_fetch_add(&foo1, 1, __ATOMIC_RELAXED);
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ax_cv_have_c_atomics=1
+
+$as_echo "#define HAVE_C_ATOMICS 1" >>confdefs.h
+
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+
+if test -z $ax_cv_have_c_atomics$ax_cv_have_gcc_atomics; then
+ as_fn_error $? "*** Atomic operations are not supported by your compiler." "$LINENO" 5
+fi
+
# glibc, AFAIK, is the only C library that makes printing a NULL to a string safe.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if your system printf is NULL-safe." >&5
$as_echo_n "checking if your system printf is NULL-safe.... " >&6; }
@@ -19330,17 +19363,6 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_fn_c_check_header_mongrel "$LINENO" "libkern/OSAtomic.h" "ac_cv_header_libkern_OSAtomic_h" "$ac_includes_default"
-if test "x$ac_cv_header_libkern_OSAtomic_h" = xyes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_OSX_ATOMICS 1
-_ACEOF
-
-fi
-
-
-
# The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
diff --git a/configure.ac b/configure.ac
index c590c6b0b..4b918837e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,12 +1,4 @@
-# Process this file with autoconf to produce a configure script.
-#
-# Make sure we use autoconf 2.60 to generate the "configure" script,
-# in case we want to commit it. Other than that, version 2.59 is
-# perfectly fine for our purposes, so people who want to modify
-# this file just have to remember to set the AC_PREREQ argument
-# to something that suits their needs.
-
-AC_PREREQ(2.60)
+AC_PREREQ(2.60a)
AC_INIT([asterisk], [trunk], [https://issues.asterisk.org])
@@ -1070,14 +1062,28 @@ AC_LINK_IFELSE(
# for FreeBSD thr_self
AC_CHECK_HEADERS([sys/thr.h])
-AC_MSG_CHECKING(for compiler atomic operations)
+AC_MSG_CHECKING(for compiler sync operations)
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([], [int foo1; int foo2 = __sync_fetch_and_add(&foo1, 1);])],
AC_MSG_RESULT(yes)
-AC_DEFINE([HAVE_GCC_ATOMICS], 1, [Define to 1 if your GCC C compiler provides atomic operations.]),
+ax_cv_have_gcc_atomics=1
+AC_DEFINE([HAVE_GCC_ATOMICS], 1, [Define to 1 if your GCC C compiler provides __sync atomic operations.]),
+AC_MSG_RESULT(no)
+)
+
+AC_MSG_CHECKING(for compiler atomic operations)
+AC_LINK_IFELSE(
+[AC_LANG_PROGRAM([], [int foo1; int foo2 = __atomic_fetch_add(&foo1, 1, __ATOMIC_RELAXED);])],
+AC_MSG_RESULT(yes)
+ax_cv_have_c_atomics=1
+AC_DEFINE([HAVE_C_ATOMICS], 1, [Define to 1 if your C compiler provides __atomic operations.]),
AC_MSG_RESULT(no)
)
+if test -z $ax_cv_have_c_atomics$ax_cv_have_gcc_atomics; then
+ AC_MSG_ERROR([*** Atomic operations are not supported by your compiler.])
+fi
+
# glibc, AFAIK, is the only C library that makes printing a NULL to a string safe.
AC_MSG_CHECKING([if your system printf is NULL-safe.])
AC_RUN_IFELSE(
@@ -1405,9 +1411,6 @@ AST_C_DEFINE_CHECK([RTLD_NOLOAD], [RTLD_NOLOAD], [dlfcn.h])
AST_C_DEFINE_CHECK([IP_MTU_DISCOVER], [IP_MTU_DISCOVER], [netinet/in.h])
-AC_CHECK_HEADER([libkern/OSAtomic.h],
- [AC_DEFINE_UNQUOTED([HAVE_OSX_ATOMICS], 1, [Define to 1 if OSX atomic operations are supported.])])
-
AC_CHECK_SIZEOF([int])
AC_CHECK_SIZEOF([long])
AC_CHECK_SIZEOF([long long])
diff --git a/contrib/ast-db-manage/config/versions/d3e4284f8707_add_prune_on_boot_to_ps_subscription_.py b/contrib/ast-db-manage/config/versions/d3e4284f8707_add_prune_on_boot_to_ps_subscription_.py
new file mode 100644
index 000000000..aa780bef3
--- /dev/null
+++ b/contrib/ast-db-manage/config/versions/d3e4284f8707_add_prune_on_boot_to_ps_subscription_.py
@@ -0,0 +1,33 @@
+"""add prune_on_boot to ps_subscription_persistence
+
+Revision ID: d3e4284f8707
+Revises: 52798ad97bdf
+Create Date: 2018-01-28 17:45:36.218123
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = 'd3e4284f8707'
+down_revision = '52798ad97bdf'
+
+from alembic import op
+import sqlalchemy as sa
+from sqlalchemy.dialects.postgresql import ENUM
+
+YESNO_NAME = 'yesno_values'
+YESNO_VALUES = ['yes', 'no']
+
+
+def upgrade():
+ ############################# Enums ##############################
+
+ # yesno_values have already been created, so use postgres enum object
+ # type to get around "already created" issue - works okay with mysql
+ yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=False)
+
+ op.add_column('ps_subscription_persistence', sa.Column('prune_on_boot', yesno_values))
+
+def downgrade():
+ if op.get_context().bind.dialect.name == 'mssql':
+ op.drop_constraint('ck_ps_subscription_persistence_prune_on_boot_yesno_values','ps_subscription_persistence')
+ op.drop_column('ps_subscription_persistence', 'prune_on_boot')
diff --git a/contrib/scripts/install_prereq b/contrib/scripts/install_prereq
index 6e7d36c2b..19da358e3 100755
--- a/contrib/scripts/install_prereq
+++ b/contrib/scripts/install_prereq
@@ -34,11 +34,21 @@ PACKAGES_DEBIAN="$PACKAGES_DEBIAN wget subversion"
# Asterisk: for ./configure --with-pjproject-bundled:
PACKAGES_DEBIAN="$PACKAGES_DEBIAN bzip2 patch python-dev"
-PACKAGES_RH="automake bzip2 gcc gcc-c++ patch ncurses-devel openssl-devel libxml2-devel unixODBC-devel libcurl-devel libogg-devel libvorbis-devel speex-devel"
-PACKAGES_RH="$PACKAGES_RH spandsp-devel freetds-devel net-snmp-devel iksemel-devel corosynclib-devel newt-devel popt-devel libtool-ltdl-devel lua-devel"
-PACKAGES_RH="$PACKAGES_RH sqlite-devel libsqlite3x-devel radiusclient-ng-devel portaudio-devel postgresql-devel libresample-devel neon-devel libical-devel"
-PACKAGES_RH="$PACKAGES_RH openldap-devel gmime22-devel sqlite2-devel mysql-devel bluez-libs-devel jack-audio-connection-kit-devel gsm-devel libedit-devel libuuid-devel"
-PACKAGES_RH="$PACKAGES_RH jansson-devel libsrtp-devel pjproject-devel subversion git libxslt-devel python-devel"
+# Basic build system:
+PACKAGES_RH="make gcc gcc-c++ pkgconfig"
+# Asterisk: basic requirements:
+PACKAGES_RH="$PACKAGES_RH libedit-devel jansson-devel libuuid-devel sqlite-devel libxml2-devel"
+# Asterisk: for addons:
+PACKAGES_RH="$PACKAGES_RH speex-devel speexdsp-devel libogg-devel libvorbis-devel alsa-lib-devel portaudio-devel libcurl-devel xmlstarlet bison flex"
+PACKAGES_RH="$PACKAGES_RH postgresql-devel unixODBC-devel libtool-ltdl-devel neon-devel gmime-devel lua-devel uriparser-devel libxslt-devel openssl-devel"
+PACKAGES_RH="$PACKAGES_RH mysql-devel bluez-libs-devel radcli-devel freetds-devel jack-audio-connection-kit-devel bash"
+PACKAGES_RH="$PACKAGES_RH net-snmp-devel iksemel-devel corosynclib-devel newt-devel popt-devel libical-devel spandsp-devel"
+PACKAGES_RH="$PACKAGES_RH libresample-devel uw-imap-devel binutils-devel libsrtp-devel gsm-devel doxygen graphviz zlib-devel openldap-devel hoard"
+PACKAGES_RH="$PACKAGES_RH codec2-devel fftw-devel libsndfile-devel unbound-devel"
+# Asterisk: for the unpackaged below:
+PACKAGES_RH="$PACKAGES_RH wget subversion"
+# Asterisk: for ./configure --with-pjproject-bundled:
+PACKAGES_RH="$PACKAGES_RH bzip2 patch python-devel"
PACKAGES_OBSD="popt gmake wget libxml libogg libvorbis curl iksemel spandsp speex iodbc freetds-0.63p1-msdblib mysql-client gmime sqlite sqlite3 jack libxslt"
PACKAGES_FBSD="autoconf gcc binutils popt gmake wget libxml2 libogg libvorbis curl iksemel spandsp speex unixODBC freetds-devel mysql55-client gmime2 sqlite"
@@ -46,7 +56,7 @@ PACKAGES_FBSD="$PACKAGES_FBSD sqlite3 libxslt jansson e2fsprogs-libuuid gsm libs
KVERS=`uname -r`
-JANSSON_VER=2.4
+JANSSON_VER=2.10
case "$1" in
test)
@@ -147,7 +157,7 @@ install_unpackaged() {
echo "*** Installing NBS (Network Broadcast Sound) ***"
svn co http://svn.digium.com/svn/nbs/trunk nbs-trunk
cd nbs-trunk
- make && make install
+ make all install
cd ..
# Only install libresample if it wasn't installed via package
@@ -155,7 +165,8 @@ install_unpackaged() {
echo "*** Installing libresample ***"
svn co http://svn.digium.com/svn/thirdparty/libresample/trunk libresample-trunk
cd libresample-trunk
- ./configure && make && make install
+ ./configure
+ make all install
cd ..
fi
@@ -164,7 +175,8 @@ install_unpackaged() {
echo "*** Installing jansson ***"
wget -O - http://www.digip.org/jansson/releases/jansson-${JANSSON_VER}.tar.gz | zcat | tar -xf -
cd jansson-${JANSSON_VER}
- ./configure && make all && make install
+ ./configure
+ make all install
cd ..
echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local.conf
/sbin/ldconfig
@@ -177,27 +189,16 @@ install_unpackaged() {
wget -O - http://github.com/cisco/libsrtp/archive/v2.tar.gz | zcat | tar -xf -
cd libsrtp-2
./configure --enable-openssl
- make shared_library uninstall install
+ make shared_library install
cd ..
echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local.conf
/sbin/ldconfig
fi
fi
- # Only install pjproject if it wasn't installed via package
if ! test -f /usr/include/pjlib.h; then
- echo "*** Installing pjproject ***"
- if [ ! -d pjproject ]; then
- git clone https://github.com/asterisk/pjproject.git
- cd pjproject
- else
- cd pjproject
- git pull
- fi
- ./configure CFLAGS="-DNDEBUG -DPJ_HAS_IPV6=1" --enable-shared --with-external-speex --with-external-gsm --with-external-srtp --disable-sound --disable-resample && make && make install
- cd ..
- echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local.conf
- /sbin/ldconfig
+ echo "PJProject not installed, yet. Therefore, please, run"
+ echo "./configure --with-pjproject-bundled"
fi
}
diff --git a/doc/appdocsxml.xslt b/doc/appdocsxml.xslt
index 511011ae8..cbdbdf7f8 100644
--- a/doc/appdocsxml.xslt
+++ b/doc/appdocsxml.xslt
@@ -78,6 +78,11 @@
</xsl:element>
<xsl:element name="parameter">
<xsl:attribute name="name">
+ <xsl:value-of select="concat(@prefix,'Language')"/>
+ </xsl:attribute>
+ </xsl:element>
+ <xsl:element name="parameter">
+ <xsl:attribute name="name">
<xsl:value-of select="concat(@prefix,'AccountCode')"/>
</xsl:attribute>
</xsl:element>
diff --git a/funcs/func_curl.c b/funcs/func_curl.c
index ebb3dce23..682ad5a42 100644
--- a/funcs/func_curl.c
+++ b/funcs/func_curl.c
@@ -920,13 +920,6 @@ static int load_module(void)
{
int res;
- if (!ast_module_check("res_curl.so")) {
- if (ast_load_resource("res_curl.so") != AST_MODULE_LOAD_SUCCESS) {
- ast_log(LOG_ERROR, "Cannot load res_curl, so func_curl cannot be loaded\n");
- return AST_MODULE_LOAD_DECLINE;
- }
- }
-
res = ast_custom_function_register_escalating(&acf_curl, AST_CFE_WRITE);
res |= ast_custom_function_register(&acf_curlopt);
@@ -940,4 +933,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Load external URL",
.load = load_module,
.unload = unload_module,
.load_pri = AST_MODPRI_REALTIME_DEPEND2,
+ .requires = "res_curl",
);
diff --git a/funcs/func_periodic_hook.c b/funcs/func_periodic_hook.c
index 958da9728..1f66747c3 100644
--- a/funcs/func_periodic_hook.c
+++ b/funcs/func_periodic_hook.c
@@ -486,11 +486,6 @@ static int load_module(void)
res = ast_custom_function_register_escalating(&hook_function, AST_CFE_BOTH);
- if (!res) {
- /* For Optional API. */
- ast_module_shutdown_ref(AST_MODULE_SELF);
- }
-
return res ? AST_MODULE_LOAD_DECLINE : AST_MODULE_LOAD_SUCCESS;
}
diff --git a/include/asterisk/agi.h b/include/asterisk/agi.h
index cb80f9570..568cd5d11 100644
--- a/include/asterisk/agi.h
+++ b/include/asterisk/agi.h
@@ -82,13 +82,12 @@ AST_OPTIONAL_API(int, ast_agi_register,
*
* Unregisters an AGI command.
*
- * \param mod Pointer to the module_info structure for the module that is unregistering the command
* \param cmd Pointer to the descriptor for the command
* \return 1 on success, 0 if the command was not already registered
*
*/
AST_OPTIONAL_API(int, ast_agi_unregister,
- (struct ast_module *mod, agi_command *cmd),
+ (agi_command *cmd),
{ return AST_OPTIONAL_API_UNAVAILABLE; });
/*!
@@ -116,7 +115,6 @@ AST_OPTIONAL_API(int, ast_agi_register_multiple,
* Unregisters a group of AGI commands, provided as an array of struct agi_command
* entries.
*
- * \param mod Pointer to the module_info structure for the module that is unregistering the commands
* \param cmd Pointer to the first entry in the array of command descriptors
* \param len Length of the array (use the ARRAY_LEN macro to determine this easily)
* \return 0 on success, -1 on failure, AST_OPTIONAL_API_UNAVAILABLE if res_agi is not loaded
@@ -125,7 +123,7 @@ AST_OPTIONAL_API(int, ast_agi_register_multiple,
* remaining commands in the array; it will not reregister the already-unregistered commands.
*/
AST_OPTIONAL_API(int, ast_agi_unregister_multiple,
- (struct ast_module *mod, struct agi_command *cmd, unsigned int len),
+ (struct agi_command *cmd, unsigned int len),
{ return AST_OPTIONAL_API_UNAVAILABLE; });
/*!
diff --git a/include/asterisk/ari.h b/include/asterisk/ari.h
index f83d5963f..865b4b00c 100644
--- a/include/asterisk/ari.h
+++ b/include/asterisk/ari.h
@@ -268,14 +268,4 @@ void ast_ari_response_created(struct ast_ari_response *response,
*/
void ast_ari_response_alloc_failed(struct ast_ari_response *response);
-/*! \brief Determines whether the res_ari module is loaded */
-#define CHECK_ARI_MODULE_LOADED() \
- do { \
- if (!ast_module_check("res_ari.so") \
- || !ast_ari_oom_json()) { \
- return AST_MODULE_LOAD_DECLINE; \
- } \
- } while(0)
-
-
#endif /* _ASTERISK_ARI_H */
diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in
index f8bd0e376..b95d52693 100644
--- a/include/asterisk/autoconfig.h.in
+++ b/include/asterisk/autoconfig.h.in
@@ -188,6 +188,9 @@
/* Define to 1 if you have the curses library. */
#undef HAVE_CURSES
+/* Define to 1 if your C compiler provides __atomic operations. */
+#undef HAVE_C_ATOMICS
+
/* Define if your system has the DAHDI headers. */
#undef HAVE_DAHDI
@@ -292,7 +295,7 @@
/* Define to 1 if you have the `ftruncate' function. */
#undef HAVE_FTRUNCATE
-/* Define to 1 if your GCC C compiler provides atomic operations. */
+/* Define to 1 if your GCC C compiler provides __sync atomic operations. */
#undef HAVE_GCC_ATOMICS
/* Define to 1 if you have the `getcwd' function. */
@@ -600,9 +603,6 @@
/* Define to 1 if you have the Open Sound System library. */
#undef HAVE_OSS
-/* Define to 1 if OSX atomic operations are supported. */
-#undef HAVE_OSX_ATOMICS
-
/* Define to 1 if your system defines the file flag O_EVTONLY in fcntl.h */
#undef HAVE_O_EVTONLY
diff --git a/include/asterisk/bridge_technology.h b/include/asterisk/bridge_technology.h
index eaea28de5..12fd49917 100644
--- a/include/asterisk/bridge_technology.h
+++ b/include/asterisk/bridge_technology.h
@@ -46,11 +46,9 @@ enum ast_bridge_preference {
* performing talking optimizations.
*/
struct ast_bridge_tech_optimizations {
- /*! The amount of time in ms that talking must be detected before
- * the dsp determines that talking has occurred */
+ /*! Minimum average magnitude threshold to determine talking by the DSP. */
unsigned int talking_threshold;
- /*! The amount of time in ms that silence must be detected before
- * the dsp determines that talking has stopped */
+ /*! Time in ms of silence necessary to declare talking stopped by the bridge. */
unsigned int silence_threshold;
/*! Whether or not the bridging technology should drop audio
* detected as silence from the mix. */
diff --git a/include/asterisk/dsp.h b/include/asterisk/dsp.h
index 7e84ebe9c..d092e6b4c 100644
--- a/include/asterisk/dsp.h
+++ b/include/asterisk/dsp.h
@@ -87,7 +87,7 @@ void ast_dsp_free(struct ast_dsp *dsp);
* created with */
unsigned int ast_dsp_get_sample_rate(const struct ast_dsp *dsp);
-/*! \brief Set threshold value for silence */
+/*! \brief Set the minimum average magnitude threshold to determine talking by the DSP. */
void ast_dsp_set_threshold(struct ast_dsp *dsp, int threshold);
/*! \brief Set number of required cadences for busy */
@@ -106,19 +106,41 @@ int ast_dsp_set_call_progress_zone(struct ast_dsp *dsp, char *zone);
busies, and call progress, all dependent upon which features are enabled */
struct ast_frame *ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp, struct ast_frame *inf);
-/*! \brief Return non-zero if this is silence. Updates "totalsilence" with the total
- number of seconds of silence */
+/*!
+ * \brief Process the audio frame for silence.
+ *
+ * \param dsp DSP processing audio media.
+ * \param f Audio frame to process.
+ * \param totalsilence Variable to set to the total accumulated silence in ms
+ * seen by the DSP since the last noise.
+ *
+ * \return Non-zero if the frame is silence.
+ */
int ast_dsp_silence(struct ast_dsp *dsp, struct ast_frame *f, int *totalsilence);
-/*! \brief Return non-zero if this is silence. Updates "totalsilence" with the total
- number of seconds of silence. Returns the average energy of the samples in the frame
- in frames_energy variable. */
+/*!
+ * \brief Process the audio frame for silence.
+ *
+ * \param dsp DSP processing audio media.
+ * \param f Audio frame to process.
+ * \param totalsilence Variable to set to the total accumulated silence in ms
+ * seen by the DSP since the last noise.
+ * \param frames_energy Variable to set to the average energy of the samples in the frame.
+ *
+ * \return Non-zero if the frame is silence.
+ */
int ast_dsp_silence_with_energy(struct ast_dsp *dsp, struct ast_frame *f, int *totalsilence, int *frames_energy);
/*!
- * \brief Return non-zero if this is noise. Updates "totalnoise" with the total
- * number of seconds of noise
+ * \brief Process the audio frame for noise.
* \since 1.6.1
+ *
+ * \param dsp DSP processing audio media.
+ * \param f Audio frame to process.
+ * \param totalnoise Variable to set to the total accumulated noise in ms
+ * seen by the DSP since the last silence.
+ *
+ * \return Non-zero if the frame is silence.
*/
int ast_dsp_noise(struct ast_dsp *dsp, struct ast_frame *f, int *totalnoise);
diff --git a/include/asterisk/file.h b/include/asterisk/file.h
index 453dc0746..c17cb327b 100644
--- a/include/asterisk/file.h
+++ b/include/asterisk/file.h
@@ -143,6 +143,11 @@ int ast_filecopy(const char *oldname, const char *newname, const char *fmt);
* \param filename the name of the file
* \param obj user data object
* \return non-zero to stop reading, otherwise zero to continue
+ *
+ * \note dir_name is not processed by realpath or other functions,
+ * symbolic links are not resolved. This ensures dir_name
+ * always starts with the exact string originally passed to
+ * \ref ast_file_read_dir or \ref ast_file_read_dirs.
*/
typedef int (*ast_file_on_file)(const char *dir_name, const char *filename, void *obj);
diff --git a/include/asterisk/linkedlists.h b/include/asterisk/linkedlists.h
index 8715cf1ad..5f50c7535 100644
--- a/include/asterisk/linkedlists.h
+++ b/include/asterisk/linkedlists.h
@@ -854,7 +854,7 @@ struct { \
*/
#define AST_LIST_REMOVE(head, elm, field) \
({ \
- __typeof(elm) __elm = (elm); \
+ typeof(elm) __elm = (elm); \
if (__elm) { \
if ((head)->first == __elm) { \
(head)->first = __elm->field.next; \
diff --git a/include/asterisk/lock.h b/include/asterisk/lock.h
index 58c9a8383..a46d04799 100644
--- a/include/asterisk/lock.h
+++ b/include/asterisk/lock.h
@@ -617,97 +617,130 @@ static void __attribute__((destructor)) fini_##rwlock(void) \
#define pthread_create __use_ast_pthread_create_instead__
#endif
-/*
- * Support for atomic instructions.
- * For platforms that have it, use the native cpu instruction to
- * implement them. For other platforms, resort to a 'slow' version
- * (defined in utils.c) that protects the atomic instruction with
- * a single lock.
- * The slow versions is always available, for testing purposes,
- * as ast_atomic_fetchadd_int_slow()
+/*!
+ * \brief Support for atomic instructions.
+ *
+ * These macros implement a uniform interface to use built-in atomic functionality.
+ * If available __atomic built-ins are prefered. Legacy __sync built-ins are used
+ * as a fallback for older compilers.
+ *
+ * Detailed documentation can be found in the GCC manual, all API's are modeled after
+ * the __atomic interfaces but using the namespace ast_atomic.
+ *
+ * The memorder argument is always ignored by legacy __sync functions. Invalid
+ * memorder arguments do not produce errors unless __atomic functions are supported
+ * as the argument is erased by the preprocessor.
+ *
+ * \note ast_atomic_fetch_nand and ast_atomic_nand_fetch purposely do not exist.
+ * It's implementation was broken prior to gcc-4.4.
+ *
+ * @{
*/
-int ast_atomic_fetchadd_int_slow(volatile int *p, int v);
-
#include "asterisk/inline_api.h"
-#if defined(HAVE_OSX_ATOMICS)
-#include "libkern/OSAtomic.h"
+#if defined(HAVE_C_ATOMICS)
+/*! Atomic += */
+#define ast_atomic_fetch_add(ptr, val, memorder) __atomic_fetch_add((ptr), (val), (memorder))
+#define ast_atomic_add_fetch(ptr, val, memorder) __atomic_add_fetch((ptr), (val), (memorder))
+
+/*! Atomic -= */
+#define ast_atomic_fetch_sub(ptr, val, memorder) __atomic_fetch_sub((ptr), (val), (memorder))
+#define ast_atomic_sub_fetch(ptr, val, memorder) __atomic_sub_fetch((ptr), (val), (memorder))
+
+/*! Atomic &= */
+#define ast_atomic_fetch_and(ptr, val, memorder) __atomic_fetch_and((ptr), (val), (memorder))
+#define ast_atomic_and_fetch(ptr, val, memorder) __atomic_and_fetch((ptr), (val), (memorder))
+
+/*! Atomic |= */
+#define ast_atomic_fetch_or(ptr, val, memorder) __atomic_fetch_or((ptr), (val), (memorder))
+#define ast_atomic_or_fetch(ptr, val, memorder) __atomic_or_fetch((ptr), (val), (memorder))
+
+/*! Atomic xor = */
+#define ast_atomic_fetch_xor(ptr, val, memorder) __atomic_fetch_xor((ptr), (val), (memorder))
+#define ast_atomic_xor_fetch(ptr, val, memorder) __atomic_xor_fetch((ptr), (val), (memorder))
+
+#if 0
+/* Atomic compare and swap
+ *
+ * See comments near the __atomic implementation for why this is disabled.
+ */
+#define ast_atomic_compare_exchange_n(ptr, expected, desired, success_memorder, failure_memorder) \
+ __atomic_compare_exchange_n((ptr), (expected), (desired), 0, success_memorder, failure_memorder)
+
+#define ast_atomic_compare_exchange(ptr, expected, desired, success_memorder, failure_memorder) \
+ __atomic_compare_exchange((ptr), (expected), (desired), 0, success_memorder, failure_memorder)
#endif
-/*! \brief Atomically add v to *p and return * the previous value of *p.
- * This can be used to handle reference counts, and the return value
- * can be used to generate unique identifiers.
+#elif defined(HAVE_GCC_ATOMICS)
+/*! Atomic += */
+#define ast_atomic_fetch_add(ptr, val, memorder) __sync_fetch_and_add((ptr), (val))
+#define ast_atomic_add_fetch(ptr, val, memorder) __sync_add_and_fetch((ptr), (val))
+
+/*! Atomic -= */
+#define ast_atomic_fetch_sub(ptr, val, memorder) __sync_fetch_and_sub((ptr), (val))
+#define ast_atomic_sub_fetch(ptr, val, memorder) __sync_sub_and_fetch((ptr), (val))
+
+/*! Atomic &= */
+#define ast_atomic_fetch_and(ptr, val, memorder) __sync_fetch_and_and((ptr), (val))
+#define ast_atomic_and_fetch(ptr, val, memorder) __sync_and_and_fetch((ptr), (val))
+
+/*! Atomic |= */
+#define ast_atomic_fetch_or(ptr, val, memorder) __sync_fetch_and_or((ptr), (val))
+#define ast_atomic_or_fetch(ptr, val, memorder) __sync_or_and_fetch((ptr), (val))
+
+/*! Atomic xor = */
+#define ast_atomic_fetch_xor(ptr, val, memorder) __sync_fetch_and_xor((ptr), (val))
+#define ast_atomic_xor_fetch(ptr, val, memorder) __sync_xor_and_fetch((ptr), (val))
+
+#if 0
+/* Atomic compare and swap
+ *
+ * The \a expected argument is a pointer, I'm guessing __atomic built-ins
+ * perform all memory reads/writes in a single atomic operation. I don't
+ * believe this is possible to exactly replicate using __sync built-ins.
+ * Will need to determine potential use cases of this feature and write a
+ * wrapper which provides consistant behavior between __sync and __atomic
+ * implementations.
*/
+#define ast_atomic_compare_exchange_n(ptr, expected, desired, success_memorder, failure_memorder) \
+ __sync_bool_compare_and_swap((ptr), *(expected), (desired))
-#if defined(HAVE_GCC_ATOMICS)
-AST_INLINE_API(int ast_atomic_fetchadd_int(volatile int *p, int v),
-{
- return __sync_fetch_and_add(p, v);
-})
-#elif defined(HAVE_OSX_ATOMICS) && (SIZEOF_INT == 4)
-AST_INLINE_API(int ast_atomic_fetchadd_int(volatile int *p, int v),
-{
- return OSAtomicAdd32(v, (int32_t *) p) - v;
-})
-#elif defined(HAVE_OSX_ATOMICS) && (SIZEOF_INT == 8)
-AST_INLINE_API(int ast_atomic_fetchadd_int(volatile int *p, int v),
-{
- return OSAtomicAdd64(v, (int64_t *) p) - v;
-})
-#elif defined (__i386__) || defined(__x86_64__)
-#ifdef sun
-AST_INLINE_API(int ast_atomic_fetchadd_int(volatile int *p, int v),
-{
- __asm __volatile (
- " lock; xaddl %0, %1 ; "
- : "+r" (v), /* 0 (result) */
- "=m" (*p) /* 1 */
- : "m" (*p)); /* 2 */
- return (v);
-})
-#else /* ifndef sun */
-AST_INLINE_API(int ast_atomic_fetchadd_int(volatile int *p, int v),
-{
- __asm __volatile (
- " lock xaddl %0, %1 ; "
- : "+r" (v), /* 0 (result) */
- "=m" (*p) /* 1 */
- : "m" (*p)); /* 2 */
- return (v);
-})
+#define ast_atomic_compare_exchange(ptr, expected, desired, success_memorder, failure_memorder) \
+ __sync_bool_compare_and_swap((ptr), *(expected), *(desired))
+#endif
+
+#else
+#error "Atomics not available."
#endif
-#else /* low performance version in utils.c */
+
+/*! Atomic flag set */
+#define ast_atomic_flag_set(ptr, val, memorder) ast_atomic_fetch_or((ptr), (val), (memorder))
+
+/*! Atomic flag clear */
+#define ast_atomic_flag_clear(ptr, val, memorder) ast_atomic_fetch_and((ptr), ~(val), (memorder))
+
+/*!
+ * \brief Atomically add v to *p and return the previous value of *p.
+ *
+ * This can be used to handle reference counts, and the return value
+ * can be used to generate unique identifiers.
+ */
AST_INLINE_API(int ast_atomic_fetchadd_int(volatile int *p, int v),
{
- return ast_atomic_fetchadd_int_slow(p, v);
+ return ast_atomic_fetch_add(p, v, __ATOMIC_RELAXED);
})
-#endif
-/*! \brief decrement *p by 1 and return true if the variable has reached 0.
+/*!
+ * \brief decrement *p by 1 and return true if the variable has reached 0.
+ *
* Useful e.g. to check if a refcount has reached 0.
*/
-#if defined(HAVE_GCC_ATOMICS)
-AST_INLINE_API(int ast_atomic_dec_and_test(volatile int *p),
-{
- return __sync_sub_and_fetch(p, 1) == 0;
-})
-#elif defined(HAVE_OSX_ATOMICS) && (SIZEOF_INT == 4)
-AST_INLINE_API(int ast_atomic_dec_and_test(volatile int *p),
-{
- return OSAtomicAdd32( -1, (int32_t *) p) == 0;
-})
-#elif defined(HAVE_OSX_ATOMICS) && (SIZEOF_INT == 8)
-AST_INLINE_API(int ast_atomic_dec_and_test(volatile int *p),
-{
- return OSAtomicAdd64( -1, (int64_t *) p) == 0;
-})
-#else
AST_INLINE_API(int ast_atomic_dec_and_test(volatile int *p),
{
- int a = ast_atomic_fetchadd_int(p, -1);
- return a == 1; /* true if the value is 0 now (so it was 1 previously) */
+ return ast_atomic_sub_fetch(p, 1, __ATOMIC_RELAXED) == 0;
})
-#endif
+
+/*! @} */
#endif /* _ASTERISK_LOCK_H */
diff --git a/include/asterisk/pbx.h b/include/asterisk/pbx.h
index c8c171a71..a40c6a45b 100644
--- a/include/asterisk/pbx.h
+++ b/include/asterisk/pbx.h
@@ -1432,7 +1432,7 @@ void ast_str_substitute_variables_varshead(struct ast_str **buf, ssize_t maxlen,
* \param c Channel variables from which to extract values, and channel to pass to any dialplan functions.
* \param headp If no channel is specified, a channel list from which to extract variable values
* \param templ Variable template to expand.
- * \param used Number of bytes read from the template.
+ * \param used Number of bytes read from the template. (May be NULL)
*/
void ast_str_substitute_variables_full(struct ast_str **buf, ssize_t maxlen, struct ast_channel *c, struct varshead *headp, const char *templ, size_t *used);
/*! @} */
diff --git a/include/asterisk/res_mwi_external.h b/include/asterisk/res_mwi_external.h
index 7698a1bd6..25de70003 100644
--- a/include/asterisk/res_mwi_external.h
+++ b/include/asterisk/res_mwi_external.h
@@ -36,22 +36,6 @@ extern "C"
/* ------------------------------------------------------------------- */
-/*!
- * \brief Increase the external MWI resource module reference count.
- * \since 12.1.0
- *
- * \return Nothing
- */
-void ast_mwi_external_ref(void);
-
-/*!
- * \brief Decrease the external MWI resource module reference count.
- * \since 12.1.0
- *
- * \return Nothing
- */
-void ast_mwi_external_unref(void);
-
struct ast_mwi_mailbox_object;
/*! \brief Convienience unref function for mailbox object. */
diff --git a/include/asterisk/res_pjproject.h b/include/asterisk/res_pjproject.h
index 8828b340c..4993be610 100644
--- a/include/asterisk/res_pjproject.h
+++ b/include/asterisk/res_pjproject.h
@@ -19,14 +19,6 @@
#ifndef _RES_PJPROJECT_H
#define _RES_PJPROJECT_H
-/*! \brief Determines whether the res_pjproject module is loaded */
-#define CHECK_PJPROJECT_MODULE_LOADED() \
- do { \
- if (!ast_module_check("res_pjproject.so")) { \
- return AST_MODULE_LOAD_DECLINE; \
- } \
- } while(0)
-
/*!
* \brief Retrieve a pjproject build option
*
@@ -79,18 +71,4 @@ void ast_pjproject_log_intercept_begin(int fd);
*/
void ast_pjproject_log_intercept_end(void);
-/*!
- * \brief Increment the res_pjproject reference count.
- *
- * This ensures graceful shutdown happens in the proper order.
- */
-void ast_pjproject_ref(void);
-
-/*!
- * \brief Decrement the res_pjproject reference count.
- *
- * This ensures graceful shutdown happens in the proper order.
- */
-void ast_pjproject_unref(void);
-
#endif /* _RES_PJPROJECT_H */
diff --git a/include/asterisk/res_pjsip.h b/include/asterisk/res_pjsip.h
index 66b99b8f7..c017e62db 100644
--- a/include/asterisk/res_pjsip.h
+++ b/include/asterisk/res_pjsip.h
@@ -933,9 +933,7 @@ enum ast_sip_contact_filter {
* \retval 0 Success
* \retval -1 Failure
*/
-#define ast_sip_register_service(module) \
- __ast_sip_register_service(module, __FILE__, __LINE__, __PRETTY_FUNCTION__)
-int __ast_sip_register_service(pjsip_module *module, const char *file, int line, const char *func);
+int ast_sip_register_service(pjsip_module *module);
/*!
* This is the opposite of ast_sip_register_service(). Unregistering a
@@ -944,9 +942,7 @@ int __ast_sip_register_service(pjsip_module *module, const char *file, int line,
*
* \param module The PJSIP module to unregister
*/
-#define ast_sip_unregister_service(module) \
- __ast_sip_unregister_service(module, __FILE__, __LINE__, __PRETTY_FUNCTION__)
-void __ast_sip_unregister_service(pjsip_module *module, const char *file, int line, const char *func);
+void ast_sip_unregister_service(pjsip_module *module);
/*!
* \brief Register a SIP authenticator
@@ -2448,10 +2444,8 @@ struct ast_sip_endpoint_formatter {
* \brief Register an endpoint formatter.
*
* \param obj the formatter to register
- * \retval 0 Success
- * \retval -1 Failure
*/
-int ast_sip_register_endpoint_formatter(struct ast_sip_endpoint_formatter *obj);
+void ast_sip_register_endpoint_formatter(struct ast_sip_endpoint_formatter *obj);
/*!
* \brief Unregister an endpoint formatter.
@@ -2627,20 +2621,14 @@ struct ast_sip_supplement {
* \retval 0 Success
* \retval -1 Failure
*/
-#define ast_sip_register_supplement(supplement) \
- __ast_sip_register_supplement(supplement, __FILE__, __LINE__, __PRETTY_FUNCTION__)
-int __ast_sip_register_supplement(struct ast_sip_supplement *supplement,
- const char *file, int line, const char *func);
+void ast_sip_register_supplement(struct ast_sip_supplement *supplement);
/*!
* \brief Unregister a an supplement to SIP out of dialog processing
*
* \param supplement The supplement to unregister
*/
-#define ast_sip_unregister_supplement(supplement) \
- __ast_sip_unregister_supplement(supplement, __FILE__, __LINE__, __PRETTY_FUNCTION__)
-void __ast_sip_unregister_supplement(struct ast_sip_supplement *supplement,
- const char *file, int line, const char *func);
+void ast_sip_unregister_supplement(struct ast_sip_supplement *supplement);
/*!
* \brief Retrieve the global MWI taskprocessor high water alert trigger level.
@@ -2764,15 +2752,6 @@ void ast_sip_get_default_realm(char *realm, size_t size);
*/
void ast_sip_get_default_from_user(char *from_user, size_t size);
-/*! \brief Determines whether the res_pjsip module is loaded */
-#define CHECK_PJSIP_MODULE_LOADED() \
- do { \
- if (!ast_module_check("res_pjsip.so") \
- || !ast_sip_get_pjsip_endpoint()) { \
- return AST_MODULE_LOAD_DECLINE; \
- } \
- } while(0)
-
/*!
* \brief Retrieve the system keep alive interval setting.
*
@@ -3006,6 +2985,18 @@ int ast_sip_str_to_dtmf(const char *dtmf_mode);
*/
typedef void (*ast_transport_monitor_shutdown_cb)(void *data);
+/*!
+ * \brief Transport shutdown monitor data matcher
+ * \since 13.20.0
+ *
+ * \param a User data to compare.
+ * \param b User data to compare.
+ *
+ * \retval 1 The data objects match
+ * \retval 0 The data objects don't match
+ */
+typedef int (*ast_transport_monitor_data_matcher)(void *a, void *b);
+
enum ast_transport_monitor_reg {
/*! \brief Successfully registered the transport monitor */
AST_TRANSPORT_MONITOR_REG_SUCCESS,
@@ -3022,37 +3013,59 @@ enum ast_transport_monitor_reg {
/*!
* \brief Register a reliable transport shutdown monitor callback.
- * \since 13.18.0
+ * \since 13.20.0
*
* \param transport Transport to monitor for shutdown.
* \param cb Who to call when transport is shutdown.
* \param ao2_data Data to pass with the callback.
*
+ * \note The data object passed will have its reference count automatically
+ * incremented by this call and automatically decremented after the callback
+ * runs or when the callback is unregistered.
+ *
+ * There is no checking for duplicate registrations.
+ *
* \return enum ast_transport_monitor_reg
*/
enum ast_transport_monitor_reg ast_sip_transport_monitor_register(pjsip_transport *transport,
ast_transport_monitor_shutdown_cb cb, void *ao2_data);
/*!
- * \brief Unregister a reliable transport shutdown monitor callback.
- * \since 13.18.0
+ * \brief Unregister a reliable transport shutdown monitor
+ * \since 13.20.0
*
* \param transport Transport to monitor for shutdown.
- * \param cb Who to call when transport is shutdown.
+ * \param cb The callback that was used for the original register.
+ * \param data Data to pass to the matcher. May be NULL and does NOT need to be an ao2 object.
+ * If NULL, all monitors with the provided callbck are unregistered.
+ * \param matches Matcher function that returns true if data matches the previously
+ * registered data object. If NULL, a simple pointer comparison is done.
+ *
+ * \note The data object passed into the original register will have its reference count
+ * automatically decremeneted.
*
* \return Nothing
*/
-void ast_sip_transport_monitor_unregister(pjsip_transport *transport, ast_transport_monitor_shutdown_cb cb);
+void ast_sip_transport_monitor_unregister(pjsip_transport *transport,
+ ast_transport_monitor_shutdown_cb cb, void *data, ast_transport_monitor_data_matcher matches);
/*!
- * \brief Unregister monitor callback from all reliable transports.
- * \since 13.18.0
+ * \brief Unregister a transport shutdown monitor from all reliable transports
+ * \since 13.20.0
+ *
+ * \param cb The callback that was used for the original register.
+ * \param data Data to pass to the matcher. May be NULL and does NOT need to be an ao2 object.
+ * If NULL, all monitors with the provided callbck are unregistered.
+ * \param matches Matcher function that returns true if ao2_data matches the previously
+ * registered data object. If NULL, a simple pointer comparison is done.
*
- * \param cb Who to call when a transport is shutdown.
+ * \note The data object passed into the original register will have its reference count
+ * automatically decremeneted.
*
* \return Nothing
*/
-void ast_sip_transport_monitor_unregister_all(ast_transport_monitor_shutdown_cb cb);
+void ast_sip_transport_monitor_unregister_all(ast_transport_monitor_shutdown_cb cb,
+ void *data, ast_transport_monitor_data_matcher matches);
/*! Transport state notification registration element. */
struct ast_sip_tpmgr_state_callback {
diff --git a/include/asterisk/res_pjsip_pubsub.h b/include/asterisk/res_pjsip_pubsub.h
index cb51db31f..e9d59a085 100644
--- a/include/asterisk/res_pjsip_pubsub.h
+++ b/include/asterisk/res_pjsip_pubsub.h
@@ -754,13 +754,4 @@ const char *ast_sip_subscription_get_body_subtype(struct ast_sip_subscription *s
*/
void ast_sip_subscription_destroy(struct ast_sip_subscription *sub);
-/*! \brief Determines whether the res_pjsip_pubsub module is loaded */
-#define CHECK_PJSIP_PUBSUB_MODULE_LOADED() \
- do { \
- CHECK_PJSIP_MODULE_LOADED(); \
- if (!ast_module_check("res_pjsip_pubsub.so")) { \
- return AST_MODULE_LOAD_DECLINE; \
- } \
- } while(0)
-
#endif /* RES_PJSIP_PUBSUB_H */
diff --git a/include/asterisk/res_pjsip_session.h b/include/asterisk/res_pjsip_session.h
index 65d463821..f6ee0f00b 100644
--- a/include/asterisk/res_pjsip_session.h
+++ b/include/asterisk/res_pjsip_session.h
@@ -579,23 +579,15 @@ void ast_sip_session_unregister_sdp_handler(struct ast_sip_session_sdp_handler *
* a module could reject an incoming request if desired.
*
* \param supplement The supplement to register
- * \retval 0 Success
- * \retval -1 Failure
*/
-#define ast_sip_session_register_supplement(supplement) \
- __ast_sip_session_register_supplement(supplement, __FILE__, __LINE__, __PRETTY_FUNCTION__)
-int __ast_sip_session_register_supplement(struct ast_sip_session_supplement *supplement,
- const char *file, int line, const char *func);
+void ast_sip_session_register_supplement(struct ast_sip_session_supplement *supplement);
/*!
* \brief Unregister a an supplement to SIP session processing
*
* \param supplement The supplement to unregister
*/
-#define ast_sip_session_unregister_supplement(supplement) \
- __ast_sip_session_unregister_supplement(supplement, __FILE__, __LINE__, __PRETTY_FUNCTION__)
-void __ast_sip_session_unregister_supplement(struct ast_sip_session_supplement *supplement,
- const char *file, int line, const char *func);
+void ast_sip_session_unregister_supplement(struct ast_sip_session_supplement *supplement);
/*!
* \brief Add supplements to a SIP session
@@ -894,13 +886,4 @@ int ast_sip_session_media_set_write_callback(struct ast_sip_session *session, st
*/
struct ast_sip_session_media *ast_sip_session_media_get_transport(struct ast_sip_session *session, struct ast_sip_session_media *session_media);
-/*! \brief Determines whether the res_pjsip_session module is loaded */
-#define CHECK_PJSIP_SESSION_MODULE_LOADED() \
- do { \
- CHECK_PJSIP_MODULE_LOADED(); \
- if (!ast_module_check("res_pjsip_session.so")) { \
- return AST_MODULE_LOAD_DECLINE; \
- } \
- } while(0)
-
#endif /* _RES_PJSIP_SESSION_H */
diff --git a/include/asterisk/stasis_app.h b/include/asterisk/stasis_app.h
index 8ef2bda1c..b0829ab73 100644
--- a/include/asterisk/stasis_app.h
+++ b/include/asterisk/stasis_app.h
@@ -46,8 +46,8 @@
* functions.
*
* Since module unload order is based on reference counting, any module that
- * uses the API defined in this file must call stasis_app_ref() when loaded,
- * and stasis_app_unref() when unloaded.
+ * uses the API defined in this file must list "res_stasis" in the requires
+ * field.
*/
#include "asterisk/channel.h"
@@ -229,18 +229,6 @@ void stasis_app_register_event_source(struct stasis_app_event_source *obj);
void stasis_app_register_event_sources(void);
/*!
- * \brief Checks to see if the given object is a core event source
- *
- * \note core event sources are currently only endpoint, bridge, and channel.
- *
- * \param obj event source object to check
- *
- * \return non-zero if core event source, otherwise 0 (false)
-
- */
-int stasis_app_is_core_event_source(struct stasis_app_event_source *obj);
-
-/*!
* \brief Unregister an application event source.
*
* \param obj the event source to unregister
@@ -850,20 +838,6 @@ struct ast_bridge *stasis_app_get_bridge(struct stasis_app_control *control);
void stasis_app_bridge_destroy(const char *bridge_id);
/*!
- * \brief Increment the res_stasis reference count.
- *
- * This ensures graceful shutdown happens in the proper order.
- */
-void stasis_app_ref(void);
-
-/*!
- * \brief Decrement the res_stasis reference count.
- *
- * This ensures graceful shutdown happens in the proper order.
- */
-void stasis_app_unref(void);
-
-/*!
* \brief Get the Stasis message sanitizer for app_stasis applications
*
* \retval The stasis message sanitizer
diff --git a/main/Makefile b/main/Makefile
index b148b6f81..7e9624ee1 100644
--- a/main/Makefile
+++ b/main/Makefile
@@ -154,7 +154,6 @@ endif
db.o: _ASTCFLAGS+=$(SQLITE3_INCLUDE)
asterisk.o: _ASTCFLAGS+=$(LIBEDIT_INCLUDE)
-loader.o: _ASTCFLAGS+=$(LIBEDIT_INCLUDE)
json.o: _ASTCFLAGS+=$(JANSSON_INCLUDE)
bucket.o: _ASTCFLAGS+=$(URIPARSER_INCLUDE)
crypt.o: _ASTCFLAGS+=$(CRYPT_INCLUDE)
diff --git a/main/asterisk.c b/main/asterisk.c
index 4c7abd68e..0214159d6 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -714,12 +714,6 @@ static int swapmode(int *used, int *total)
ast_free(swdev);
return 1;
}
-#elif defined(HAVE_SYSCTL) && !defined(HAVE_SYSINFO)
-static int swapmode(int *used, int *total)
-{
- *used = *total = 0;
- return 1;
-}
#endif
#if defined(HAVE_SYSINFO) || defined(HAVE_SYSCTL)
@@ -728,11 +722,11 @@ static char *handle_show_sysinfo(struct ast_cli_entry *e, int cmd, struct ast_cl
{
uint64_t physmem, freeram;
#if defined(HAVE_SYSINFO) || defined(HAVE_SWAPCTL)
+ int totalswap = 0;
uint64_t freeswap = 0;
#endif
int nprocs = 0;
long uptime = 0;
- int totalswap = 0;
#if defined(HAVE_SYSINFO)
struct sysinfo sys_info;
#elif defined(HAVE_SYSCTL)
@@ -740,7 +734,10 @@ static char *handle_show_sysinfo(struct ast_cli_entry *e, int cmd, struct ast_cl
struct vmtotal vmtotal;
struct timeval boottime;
time_t now;
- int mib[2], pagesize, usedswap = 0;
+ int mib[2], pagesize;
+#if defined(HAVE_SWAPCTL)
+ int usedswap = 0;
+#endif
size_t len;
#endif
@@ -800,8 +797,10 @@ static char *handle_show_sysinfo(struct ast_cli_entry *e, int cmd, struct ast_cl
sysctl(mib, 2, &vmtotal, &len, NULL, 0);
freeram = (vmtotal.t_free << pageshift);
/* generate swap usage and totals */
+#if defined(HAVE_SWAPCTL)
swapmode(&usedswap, &totalswap);
freeswap = (totalswap - usedswap);
+#endif
/* grab number of processes */
#if defined(__OpenBSD__)
mib[0] = CTL_KERN;
@@ -4546,20 +4545,7 @@ static void asterisk_daemon(int isroot, const char *runuser, const char *rungrou
check_init(ast_device_state_engine_init(), "Device State Engine");
check_init(ast_presence_state_engine_init(), "Presence State Engine");
check_init(ast_dns_system_resolver_init(), "Default DNS resolver");
- check_init(load_modules(1), "Module Preload");
- check_init(ast_features_init(), "Call Features");
- check_init(dnsmgr_init(), "DNS manager");
check_init(ast_security_stasis_init(), "Security Stasis Topic and Events");
- check_init(ast_named_acl_init(), "Named ACL system");
-
- ast_http_init(); /* Start the HTTP server, if needed */
-
- check_init(ast_indications_init(), "Indication Tone Handling");
- check_init(ast_cdr_engine_init(), "CDR Engine");
-
- ast_dsp_init();
- ast_udptl_init();
-
check_init(ast_image_init(), "Image");
check_init(ast_file_init(), "Generic File Format Support");
check_init(load_pbx(), "load_pbx");
@@ -4570,10 +4556,27 @@ static void asterisk_daemon(int isroot, const char *runuser, const char *rungrou
check_init(load_pbx_app(), "PBX Application Support");
check_init(load_pbx_hangup_handler(), "PBX Hangup Handler Support");
check_init(ast_local_init(), "Local Proxy Channel Driver");
+
+ /* We should avoid most config loads before this point as they can't use realtime. */
+ check_init(load_modules(1), "Module Preload");
+
+ /* Initialize core modules that have config files. These should be converted to
+ * built-in modules with load priority after realtime, that way users will not
+ * need to 'preload' realtime modules. */
+ check_init(ast_features_init(), "Call Features");
+ check_init(dnsmgr_init(), "DNS manager");
+ check_init(ast_named_acl_init(), "Named ACL system");
+ ast_http_init();
+ check_init(ast_indications_init(), "Indication Tone Handling");
+ check_init(ast_cdr_engine_init(), "CDR Engine");
+ ast_dsp_init();
+ ast_udptl_init();
check_init(ast_cel_engine_init(), "CEL Engine");
check_init(init_manager(), "Asterisk Manager Interface");
check_init(ast_enum_init(), "ENUM Support");
check_init(ast_cc_init(), "Call Completion Supplementary Services");
+
+ /* Load remaining modules */
check_init(load_modules(0), "Module");
/*
diff --git a/main/dsp.c b/main/dsp.c
index e4e7fd3eb..8b39fe55e 100644
--- a/main/dsp.c
+++ b/main/dsp.c
@@ -122,12 +122,19 @@ static struct progress {
{ GSAMP_SIZE_UK, { 350, 400, 440 } }, /*!< UK */
};
-/*!\brief This value is the minimum threshold, calculated by averaging all
- * of the samples within a frame, for which a frame is determined to either
- * be silence (below the threshold) or noise (above the threshold). Please
- * note that while the default threshold is an even exponent of 2, there is
- * no requirement that it be so. The threshold will accept any value between
- * 0 and 32767.
+/*!
+ * \brief Default minimum average magnitude threshold to determine talking/noise by the DSP.
+ *
+ * \details
+ * The magnitude calculated for this threshold is determined by
+ * averaging the absolute value of all samples within a frame.
+ *
+ * This value is the threshold for which a frame's average magnitude
+ * is determined to either be silence (below the threshold) or
+ * noise/talking (at or above the threshold). Please note that while
+ * the default threshold is an even exponent of 2, there is no
+ * requirement that it be so. The threshold will work for any value
+ * between 1 and 2^15.
*/
#define DEFAULT_THRESHOLD 512
@@ -397,7 +404,9 @@ typedef struct {
struct ast_dsp {
struct ast_frame f;
int threshold;
+ /*! Accumulated total silence in ms since last talking/noise. */
int totalsilence;
+ /*! Accumulated total talking/noise in ms since last silence. */
int totalnoise;
int features;
int ringtimeout;
diff --git a/main/editline/el.h b/main/editline/el.h
index 641081e87..386d84cce 100644
--- a/main/editline/el.h
+++ b/main/editline/el.h
@@ -55,9 +55,9 @@
#define EL_BUFSIZ 1024 /* Maximum line size */
-#define HANDLE_SIGNALS 1<<0
-#define NO_TTY 1<<1
-#define EDIT_DISABLED 1<<2
+#define HANDLE_SIGNALS 0x01
+#define NO_TTY 0x02
+#define EDIT_DISABLED 0x04
typedef int bool_t; /* True or not */
diff --git a/main/loader.c b/main/loader.c
index da508f3de..6b29f0e96 100644
--- a/main/loader.c
+++ b/main/loader.c
@@ -36,7 +36,6 @@
#include "asterisk/_private.h"
#include "asterisk/paths.h" /* use ast_config_AST_MODULE_DIR */
#include <dirent.h>
-#include <editline/readline.h>
#include "asterisk/dlinkedlists.h"
#include "asterisk/module.h"
@@ -56,6 +55,7 @@
#include "asterisk/app.h"
#include "asterisk/test.h"
#include "asterisk/sounds_index.h"
+#include "asterisk/cli.h"
#include <dlfcn.h>
@@ -1036,57 +1036,55 @@ static int module_matches_helper_type(struct ast_module *mod, enum ast_module_he
}
}
-static char *module_load_helper(const char *word, int state)
+struct module_load_word {
+ const char *word;
+ size_t len;
+ size_t moddir_len;
+};
+
+static int module_load_helper_on_file(const char *dir_name, const char *filename, void *obj)
{
+ struct module_load_word *word = obj;
struct ast_module *mod;
- int which = 0;
- char *name;
- char *ret = NULL;
- char *editline_ret;
- char fullpath[PATH_MAX];
- int idx = 0;
- /* This is needed to avoid listing modules that are already running. */
- AST_VECTOR(, char *) running_modules;
+ char *filename_merged = NULL;
- AST_VECTOR_INIT(&running_modules, 200);
+ /* dir_name will never be shorter than word->moddir_len. */
+ dir_name += word->moddir_len;
+ if (!ast_strlen_zero(dir_name)) {
+ ast_assert(dir_name[0] == '/');
- AST_DLLIST_LOCK(&module_list);
- AST_DLLIST_TRAVERSE(&module_list, mod, entry) {
- if (mod->flags.running) {
- AST_VECTOR_APPEND(&running_modules, mod->resource);
+ dir_name += 1;
+ if (ast_asprintf(&filename_merged, "%s/%s", dir_name, filename) < 0) {
+ /* If we can't allocate the string just give up! */
+ return -1;
}
+ filename = filename_merged;
}
- if (word[0] == '/') {
- /* BUGBUG: we should not support this. */
- ast_copy_string(fullpath, word, sizeof(fullpath));
- } else {
- snprintf(fullpath, sizeof(fullpath), "%s/%s", ast_config_AST_MODULE_DIR, word);
+ if (!strncasecmp(filename, word->word, word->len)) {
+ /* Don't list files that are already loaded! */
+ mod = find_resource(filename, 0);
+ if (!mod || !mod->flags.running) {
+ ast_cli_completion_add(ast_strdup(filename));
+ }
}
- /*
- * This is ugly that we keep calling filename_completion_function.
- * The only way to avoid this would be to make a copy of the function
- * that skips matches found in the running_modules vector.
- */
- while (!ret && (name = editline_ret = filename_completion_function(fullpath, idx++))) {
- if (word[0] != '/') {
- name += (strlen(ast_config_AST_MODULE_DIR) + 1);
- }
+ ast_free(filename_merged);
- /* Don't list files that are already loaded! */
- if (!AST_VECTOR_GET_CMP(&running_modules, name, !strcasecmp) && ++which > state) {
- ret = ast_strdup(name);
- }
+ return 0;
+}
- ast_std_free(editline_ret);
- }
+static void module_load_helper(const char *word)
+{
+ struct module_load_word word_l = {
+ .word = word,
+ .len = strlen(word),
+ .moddir_len = strlen(ast_config_AST_MODULE_DIR),
+ };
- /* Do not clean-up the elements, they belong to module_list. */
- AST_VECTOR_FREE(&running_modules);
+ AST_DLLIST_LOCK(&module_list);
+ ast_file_read_dirs(ast_config_AST_MODULE_DIR, module_load_helper_on_file, &word_l, -1);
AST_DLLIST_UNLOCK(&module_list);
-
- return ret;
}
char *ast_module_helper(const char *line, const char *word, int pos, int state, int rpos, enum ast_module_helper_type type)
@@ -1101,7 +1099,9 @@ char *ast_module_helper(const char *line, const char *word, int pos, int state,
}
if (type == AST_MODULE_HELPER_LOAD) {
- return module_load_helper(word, state);
+ module_load_helper(word);
+
+ return NULL;
}
if (type == AST_MODULE_HELPER_RELOAD) {
@@ -1394,7 +1394,7 @@ static enum ast_module_load_result start_resource(struct ast_module *mod)
}
AST_VECTOR_FREE(&missing);
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
if (!ast_fully_booted) {
@@ -1580,6 +1580,7 @@ static int start_resource_list(struct module_vector *resources, int *mod_count)
struct ast_module *mod = AST_VECTOR_REMOVE(resources, 0, 1);
enum ast_module_load_result lres;
+retry_load:
lres = start_resource_attempt(mod, mod_count);
if (lres == AST_MODULE_LOAD_SUCCESS) {
/* No missing dependencies, successful. */
@@ -1598,13 +1599,18 @@ static int start_resource_list(struct module_vector *resources, int *mod_count)
res = module_deps_missing_recursive(mod, &missingdeps);
if (res) {
- break;
+ AST_VECTOR_RESET(&missingdeps, AST_VECTOR_ELEM_CLEANUP_NOOP);
+ ast_log(LOG_ERROR, "Failed to resolve dependencies for %s\n", ast_module_name(mod));
+ mod->flags.declined = 1;
+
+ continue;
}
if (!AST_VECTOR_SIZE(&missingdeps)) {
- ast_log(LOG_WARNING, "%s isn't missing any dependencies but still didn't start\n",
- ast_module_name(mod));
- /* Dependencies were met but the module failed to start. */
+ ast_log(LOG_WARNING, "%s load function returned an invalid result. "
+ "This is a bug in the module.\n", ast_module_name(mod));
+ /* Dependencies were met but the module failed to start and the result
+ * code was not AST_MODULE_LOAD_FAILURE or AST_MODULE_LOAD_DECLINE. */
res = -1;
break;
}
@@ -1637,17 +1643,17 @@ static int start_resource_list(struct module_vector *resources, int *mod_count)
}
if (AST_VECTOR_SIZE(&missingdeps)) {
- ast_log(LOG_ERROR, "Failed to load %s due to unfilled dependencies.\n",
+ ast_log(LOG_WARNING, "Failed to load %s due to unfilled dependencies.\n",
ast_module_name(mod));
- res = -1;
- break;
- }
+ mod->flags.declined = 1;
+ AST_VECTOR_RESET(&missingdeps, AST_VECTOR_ELEM_CLEANUP_NOOP);
- res = start_resource_attempt(mod, mod_count);
- if (res) {
- ast_log(LOG_ERROR, "Failed to load %s: %d\n", ast_module_name(mod), res);
- break;
+ continue;
}
+
+ /* If we're here it means that we started with missingdeps and they're all loaded
+ * now. It's impossible to reach this point a second time for the same module. */
+ goto retry_load;
}
AST_VECTOR_FREE(&missingdeps);
diff --git a/main/manager.c b/main/manager.c
index 2df2a46fb..177959ac8 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -9505,23 +9505,16 @@ struct ast_datastore *astman_datastore_find(struct mansession *s, const struct a
}
int ast_str_append_event_header(struct ast_str **fields_string,
- const char *header, const char *value)
+ const char *header, const char *value)
{
- struct ast_str *working_str = *fields_string;
-
- if (!working_str) {
- working_str = ast_str_create(128);
- if (!working_str) {
+ if (!*fields_string) {
+ *fields_string = ast_str_create(128);
+ if (!*fields_string) {
return -1;
}
- *fields_string = working_str;
}
- ast_str_append(&working_str, 0,
- "%s: %s\r\n",
- header, value);
-
- return 0;
+ return (ast_str_append(fields_string, 0, "%s: %s\r\n", header, value) < 0) ? -1 : 0;
}
static void manager_event_blob_dtor(void *obj)
diff --git a/main/manager_channels.c b/main/manager_channels.c
index 81dafd74b..37269a917 100644
--- a/main/manager_channels.c
+++ b/main/manager_channels.c
@@ -488,16 +488,17 @@ struct ast_str *ast_manager_build_channel_state_string_prefix(
const struct ast_channel_snapshot *snapshot,
const char *prefix)
{
- struct ast_str *out = ast_str_create(1024);
- int res = 0;
- char *caller_name, *connected_name;
+ struct ast_str *out;
+ char *caller_name;
+ char *connected_name;
+ int res;
- if (!out) {
+ if (snapshot->tech_properties & AST_CHAN_TP_INTERNAL) {
return NULL;
}
- if (snapshot->tech_properties & AST_CHAN_TP_INTERNAL) {
- ast_free(out);
+ out = ast_str_create(1024);
+ if (!out) {
return NULL;
}
@@ -534,10 +535,11 @@ struct ast_str *ast_manager_build_channel_state_string_prefix(
prefix, snapshot->uniqueid,
prefix, snapshot->linkedid);
+ ast_free(caller_name);
+ ast_free(connected_name);
+
if (!res) {
ast_free(out);
- ast_free(caller_name);
- ast_free(connected_name);
return NULL;
}
@@ -553,9 +555,6 @@ struct ast_str *ast_manager_build_channel_state_string_prefix(
}
}
- ast_free(caller_name);
- ast_free(connected_name);
-
return out;
}
diff --git a/main/pbx_variables.c b/main/pbx_variables.c
index eede21316..1dc0fc04a 100644
--- a/main/pbx_variables.c
+++ b/main/pbx_variables.c
@@ -396,51 +396,74 @@ const char *ast_str_retrieve_variable(struct ast_str **str, ssize_t maxlen, stru
void ast_str_substitute_variables_full(struct ast_str **buf, ssize_t maxlen, struct ast_channel *c, struct varshead *headp, const char *templ, size_t *used)
{
/* Substitutes variables into buf, based on string templ */
- char *cp4 = NULL;
const char *whereweare;
- int orig_size = 0;
- int offset, offset2, isfunction;
- const char *nextvar, *nextexp, *nextthing;
- const char *vars, *vare;
- char *finalvars;
- int pos, brackets, needsub, len;
- struct ast_str *substr1 = ast_str_create(16), *substr2 = NULL, *substr3 = ast_str_create(16);
+ struct ast_str *substr1 = ast_str_create(16);
+ struct ast_str *substr2 = NULL;
+ struct ast_str *substr3 = ast_str_create(16);
ast_str_reset(*buf);
+
+ if (!substr1 || !substr3) {
+ if (used) {
+ *used = ast_str_strlen(*buf);
+ }
+ ast_free(substr1);
+ ast_free(substr3);
+ return;
+ }
+
whereweare = templ;
while (!ast_strlen_zero(whereweare)) {
+ const char *nextvar = NULL;
+ const char *nextexp = NULL;
+ const char *nextthing;
+ const char *vars;
+ const char *vare;
+ char *finalvars;
+ int pos;
+ int brackets;
+ int needsub;
+ int len;
+
/* reset our buffer */
ast_str_reset(substr3);
- /* Assume we're copying the whole remaining string */
- pos = strlen(whereweare);
- nextvar = NULL;
- nextexp = NULL;
+ /* Determine how much simply needs to be copied to the output buf. */
nextthing = strchr(whereweare, '$');
if (nextthing) {
+ pos = nextthing - whereweare;
switch (nextthing[1]) {
case '{':
+ /* Variable substitution */
nextvar = nextthing;
- pos = nextvar - whereweare;
break;
case '[':
+ /* Expression substitution */
nextexp = nextthing;
- pos = nextexp - whereweare;
break;
default:
- pos = 1;
+ /* '$' is not part of a substitution so include it too. */
+ ++pos;
+ break;
}
+ } else {
+ /* We're copying the whole remaining string */
+ pos = strlen(whereweare);
}
if (pos) {
/* Copy that many bytes */
ast_str_append_substr(buf, maxlen, whereweare, pos);
- templ += pos;
whereweare += pos;
}
if (nextvar) {
+ int offset;
+ int offset2;
+ int isfunction;
+ int res;
+
/* We have a variable. Find the start and end, and determine
if we are going to have to recursively call ourselves on the
contents */
@@ -452,33 +475,42 @@ void ast_str_substitute_variables_full(struct ast_str **buf, ssize_t maxlen, str
while (brackets && *vare) {
if ((vare[0] == '$') && (vare[1] == '{')) {
needsub++;
+ brackets++;
+ vare++;
} else if (vare[0] == '{') {
brackets++;
} else if (vare[0] == '}') {
brackets--;
- } else if ((vare[0] == '$') && (vare[1] == '['))
+ } else if ((vare[0] == '$') && (vare[1] == '[')) {
needsub++;
+ vare++;
+ }
vare++;
}
- if (brackets)
+ len = vare - vars;
+ if (brackets) {
ast_log(LOG_WARNING, "Error in extension logic (missing '}')\n");
- len = vare - vars - 1;
+ } else {
+ /* Don't count the closing '}' in the length. */
+ --len;
+ }
/* Skip totally over variable string */
- whereweare += (len + 3);
+ whereweare = vare;
- /* Store variable name (and truncate) */
+ /* Store variable name expression to lookup. */
ast_str_set_substr(&substr1, 0, vars, len);
ast_debug(5, "Evaluating '%s' (from '%s' len %d)\n", ast_str_buffer(substr1), vars, len);
/* Substitute if necessary */
if (needsub) {
- size_t my_used;
-
if (!substr2) {
substr2 = ast_str_create(16);
+ if (!substr2) {
+ continue;
+ }
}
- ast_str_substitute_variables_full(&substr2, 0, c, headp, ast_str_buffer(substr1), &my_used);
+ ast_str_substitute_variables_full(&substr2, 0, c, headp, ast_str_buffer(substr1), NULL);
finalvars = ast_str_buffer(substr2);
} else {
finalvars = ast_str_buffer(substr1);
@@ -488,28 +520,32 @@ void ast_str_substitute_variables_full(struct ast_str **buf, ssize_t maxlen, str
if (isfunction) {
/* Evaluate function */
if (c || !headp) {
- cp4 = ast_func_read2(c, finalvars, &substr3, 0) ? NULL : ast_str_buffer(substr3);
+ res = ast_func_read2(c, finalvars, &substr3, 0);
} else {
struct varshead old;
- struct ast_channel *bogus = ast_dummy_channel_alloc();
+ struct ast_channel *bogus;
+
+ bogus = ast_dummy_channel_alloc();
if (bogus) {
- memcpy(&old, ast_channel_varshead(bogus), sizeof(old));
- memcpy(ast_channel_varshead(bogus), headp, sizeof(*ast_channel_varshead(bogus)));
- cp4 = ast_func_read2(c, finalvars, &substr3, 0) ? NULL : ast_str_buffer(substr3);
+ old = *ast_channel_varshead(bogus);
+ *ast_channel_varshead(bogus) = *headp;
+ res = ast_func_read2(bogus, finalvars, &substr3, 0);
/* Don't deallocate the varshead that was passed in */
- memcpy(ast_channel_varshead(bogus), &old, sizeof(*ast_channel_varshead(bogus)));
+ *ast_channel_varshead(bogus) = old;
ast_channel_unref(bogus);
} else {
- ast_log(LOG_ERROR, "Unable to allocate bogus channel for variable substitution. Function results may be blank.\n");
+ ast_log(LOG_ERROR, "Unable to allocate bogus channel for function value substitution.\n");
+ res = -1;
}
}
- ast_debug(2, "Function %s result is '%s'\n", finalvars, cp4 ? cp4 : "(null)");
+ ast_debug(2, "Function %s result is '%s'\n",
+ finalvars, res ? "" : ast_str_buffer(substr3));
} else {
/* Retrieve variable value */
ast_str_retrieve_variable(&substr3, 0, c, headp, finalvars);
- cp4 = ast_str_buffer(substr3);
+ res = 0;
}
- if (cp4) {
+ if (!res) {
ast_str_substring(substr3, offset, offset2);
ast_str_append(buf, maxlen, "%s", ast_str_buffer(substr3));
}
@@ -537,24 +573,29 @@ void ast_str_substitute_variables_full(struct ast_str **buf, ssize_t maxlen, str
}
vare++;
}
- if (brackets)
+ len = vare - vars;
+ if (brackets) {
ast_log(LOG_WARNING, "Error in extension logic (missing ']')\n");
- len = vare - vars - 1;
+ } else {
+ /* Don't count the closing ']' in the length. */
+ --len;
+ }
/* Skip totally over expression */
- whereweare += (len + 3);
+ whereweare = vare;
- /* Store variable name (and truncate) */
+ /* Store expression to evaluate. */
ast_str_set_substr(&substr1, 0, vars, len);
/* Substitute if necessary */
if (needsub) {
- size_t my_used;
-
if (!substr2) {
substr2 = ast_str_create(16);
+ if (!substr2) {
+ continue;
+ }
}
- ast_str_substitute_variables_full(&substr2, 0, c, headp, ast_str_buffer(substr1), &my_used);
+ ast_str_substitute_variables_full(&substr2, 0, c, headp, ast_str_buffer(substr1), NULL);
finalvars = ast_str_buffer(substr2);
} else {
finalvars = ast_str_buffer(substr1);
@@ -566,7 +607,9 @@ void ast_str_substitute_variables_full(struct ast_str **buf, ssize_t maxlen, str
ast_str_append(buf, maxlen, "%s", ast_str_buffer(substr3));
}
}
- *used = ast_str_strlen(*buf) - orig_size;
+ if (used) {
+ *used = ast_str_strlen(*buf);
+ }
ast_free(substr1);
ast_free(substr2);
ast_free(substr3);
@@ -574,49 +617,58 @@ void ast_str_substitute_variables_full(struct ast_str **buf, ssize_t maxlen, str
void ast_str_substitute_variables(struct ast_str **buf, ssize_t maxlen, struct ast_channel *chan, const char *templ)
{
- size_t used;
- ast_str_substitute_variables_full(buf, maxlen, chan, NULL, templ, &used);
+ ast_str_substitute_variables_full(buf, maxlen, chan, NULL, templ, NULL);
}
void ast_str_substitute_variables_varshead(struct ast_str **buf, ssize_t maxlen, struct varshead *headp, const char *templ)
{
- size_t used;
- ast_str_substitute_variables_full(buf, maxlen, NULL, headp, templ, &used);
+ ast_str_substitute_variables_full(buf, maxlen, NULL, headp, templ, NULL);
}
void pbx_substitute_variables_helper_full(struct ast_channel *c, struct varshead *headp, const char *cp1, char *cp2, int count, size_t *used)
{
/* Substitutes variables into cp2, based on string cp1, cp2 NO LONGER NEEDS TO BE ZEROED OUT!!!! */
- char *cp4 = NULL;
- const char *whereweare, *orig_cp2 = cp2;
- int length, offset, offset2, isfunction;
+ const char *whereweare;
+ const char *orig_cp2 = cp2;
char *workspace = NULL;
- char *ltmp = NULL, *var = NULL;
- char *nextvar, *nextexp, *nextthing;
- char *vars, *vare;
- int pos, brackets, needsub, len;
+ char *ltmp = NULL;
+ char *var = NULL;
*cp2 = 0; /* just in case nothing ends up there */
whereweare = cp1;
while (!ast_strlen_zero(whereweare) && count) {
- /* Assume we're copying the whole remaining string */
- pos = strlen(whereweare);
- nextvar = NULL;
- nextexp = NULL;
+ char *nextvar = NULL;
+ char *nextexp = NULL;
+ char *nextthing;
+ char *vars;
+ char *vare;
+ int length;
+ int pos;
+ int brackets;
+ int needsub;
+ int len;
+
+ /* Determine how much simply needs to be copied to the output buf. */
nextthing = strchr(whereweare, '$');
if (nextthing) {
+ pos = nextthing - whereweare;
switch (nextthing[1]) {
case '{':
+ /* Variable substitution */
nextvar = nextthing;
- pos = nextvar - whereweare;
break;
case '[':
+ /* Expression substitution */
nextexp = nextthing;
- pos = nextexp - whereweare;
break;
default:
- pos = 1;
+ /* '$' is not part of a substitution so include it too. */
+ ++pos;
+ break;
}
+ } else {
+ /* We're copying the whole remaining string */
+ pos = strlen(whereweare);
}
if (pos) {
@@ -634,6 +686,11 @@ void pbx_substitute_variables_helper_full(struct ast_channel *c, struct varshead
}
if (nextvar) {
+ int offset;
+ int offset2;
+ int isfunction;
+ char *cp4;
+
/* We have a variable. Find the start and end, and determine
if we are going to have to recursively call ourselves on the
contents */
@@ -645,35 +702,41 @@ void pbx_substitute_variables_helper_full(struct ast_channel *c, struct varshead
while (brackets && *vare) {
if ((vare[0] == '$') && (vare[1] == '{')) {
needsub++;
+ brackets++;
+ vare++;
} else if (vare[0] == '{') {
brackets++;
} else if (vare[0] == '}') {
brackets--;
- } else if ((vare[0] == '$') && (vare[1] == '['))
+ } else if ((vare[0] == '$') && (vare[1] == '[')) {
needsub++;
+ vare++;
+ }
vare++;
}
- if (brackets)
+ len = vare - vars;
+ if (brackets) {
ast_log(LOG_WARNING, "Error in extension logic (missing '}')\n");
- len = vare - vars - 1;
+ } else {
+ /* Don't count the closing '}' in the length. */
+ --len;
+ }
/* Skip totally over variable string */
- whereweare += (len + 3);
+ whereweare = vare;
if (!var)
var = ast_alloca(VAR_BUF_SIZE);
- /* Store variable name (and truncate) */
+ /* Store variable name expression to lookup (and truncate). */
ast_copy_string(var, vars, len + 1);
/* Substitute if necessary */
if (needsub) {
- size_t my_used;
-
if (!ltmp) {
ltmp = ast_alloca(VAR_BUF_SIZE);
}
- pbx_substitute_variables_helper_full(c, headp, var, ltmp, VAR_BUF_SIZE - 1, &my_used);
+ pbx_substitute_variables_helper_full(c, headp, var, ltmp, VAR_BUF_SIZE - 1, NULL);
vars = ltmp;
} else {
vars = var;
@@ -691,16 +754,19 @@ void pbx_substitute_variables_helper_full(struct ast_channel *c, struct varshead
cp4 = ast_func_read(c, vars, workspace, VAR_BUF_SIZE) ? NULL : workspace;
else {
struct varshead old;
- struct ast_channel *c = ast_dummy_channel_alloc();
- if (c) {
- memcpy(&old, ast_channel_varshead(c), sizeof(old));
- memcpy(ast_channel_varshead(c), headp, sizeof(*ast_channel_varshead(c)));
- cp4 = ast_func_read(c, vars, workspace, VAR_BUF_SIZE) ? NULL : workspace;
+ struct ast_channel *bogus;
+
+ bogus = ast_dummy_channel_alloc();
+ if (bogus) {
+ old = *ast_channel_varshead(bogus);
+ *ast_channel_varshead(bogus) = *headp;
+ cp4 = ast_func_read(bogus, vars, workspace, VAR_BUF_SIZE) ? NULL : workspace;
/* Don't deallocate the varshead that was passed in */
- memcpy(ast_channel_varshead(c), &old, sizeof(*ast_channel_varshead(c)));
- c = ast_channel_unref(c);
+ *ast_channel_varshead(bogus) = old;
+ ast_channel_unref(bogus);
} else {
- ast_log(LOG_ERROR, "Unable to allocate bogus channel for variable substitution. Function results may be blank.\n");
+ ast_log(LOG_ERROR, "Unable to allocate bogus channel for function value substitution.\n");
+ cp4 = NULL;
}
}
ast_debug(2, "Function %s result is '%s'\n", vars, cp4 ? cp4 : "(null)");
@@ -743,34 +809,35 @@ void pbx_substitute_variables_helper_full(struct ast_channel *c, struct varshead
}
vare++;
}
- if (brackets)
+ len = vare - vars;
+ if (brackets) {
ast_log(LOG_WARNING, "Error in extension logic (missing ']')\n");
- len = vare - vars - 1;
+ } else {
+ /* Don't count the closing ']' in the length. */
+ --len;
+ }
/* Skip totally over expression */
- whereweare += (len + 3);
+ whereweare = vare;
if (!var)
var = ast_alloca(VAR_BUF_SIZE);
- /* Store variable name (and truncate) */
+ /* Store expression to evaluate (and truncate). */
ast_copy_string(var, vars, len + 1);
/* Substitute if necessary */
if (needsub) {
- size_t my_used;
-
if (!ltmp) {
ltmp = ast_alloca(VAR_BUF_SIZE);
}
- pbx_substitute_variables_helper_full(c, headp, var, ltmp, VAR_BUF_SIZE - 1, &my_used);
+ pbx_substitute_variables_helper_full(c, headp, var, ltmp, VAR_BUF_SIZE - 1, NULL);
vars = ltmp;
} else {
vars = var;
}
length = ast_expr(vars, cp2, count, c);
-
if (length) {
ast_debug(1, "Expression result is '%s'\n", cp2);
count -= length;
@@ -779,19 +846,19 @@ void pbx_substitute_variables_helper_full(struct ast_channel *c, struct varshead
}
}
}
- *used = cp2 - orig_cp2;
+ if (used) {
+ *used = cp2 - orig_cp2;
+ }
}
void pbx_substitute_variables_helper(struct ast_channel *c, const char *cp1, char *cp2, int count)
{
- size_t used;
- pbx_substitute_variables_helper_full(c, (c) ? ast_channel_varshead(c) : NULL, cp1, cp2, count, &used);
+ pbx_substitute_variables_helper_full(c, (c) ? ast_channel_varshead(c) : NULL, cp1, cp2, count, NULL);
}
void pbx_substitute_variables_varshead(struct varshead *headp, const char *cp1, char *cp2, int count)
{
- size_t used;
- pbx_substitute_variables_helper_full(NULL, headp, cp1, cp2, count, &used);
+ pbx_substitute_variables_helper_full(NULL, headp, cp1, cp2, count, NULL);
}
/*! \brief CLI support for listing global variables in a parseable way */
diff --git a/main/utils.c b/main/utils.c
index 85228c183..7f74f40be 100644
--- a/main/utils.c
+++ b/main/utils.c
@@ -1985,18 +1985,6 @@ char *ast_to_camel_case_delim(const char *s, const char *delim)
return res;
}
-AST_MUTEX_DEFINE_STATIC(fetchadd_m); /* used for all fetc&add ops */
-
-int ast_atomic_fetchadd_int_slow(volatile int *p, int v)
-{
- int ret;
- ast_mutex_lock(&fetchadd_m);
- ret = *p;
- *p += v;
- ast_mutex_unlock(&fetchadd_m);
- return ret;
-}
-
/*! \brief
* get values from config variables.
*/
diff --git a/res/ari/resource_bridges.c b/res/ari/resource_bridges.c
index a320c2987..9808288e9 100644
--- a/res/ari/resource_bridges.c
+++ b/res/ari/resource_bridges.c
@@ -24,8 +24,6 @@
*/
/*** MODULEINFO
- <depend type="module">res_stasis_recording</depend>
- <depend type="module">res_stasis_playback</depend>
<support_level>core</support_level>
***/
diff --git a/res/ari/resource_channels.c b/res/ari/resource_channels.c
index 6b4f26c25..cdf0f8820 100644
--- a/res/ari/resource_channels.c
+++ b/res/ari/resource_channels.c
@@ -24,10 +24,6 @@
*/
/*** MODULEINFO
- <depend type="module">res_stasis_answer</depend>
- <depend type="module">res_stasis_playback</depend>
- <depend type="module">res_stasis_recording</depend>
- <depend type="module">res_stasis_snoop</depend>
<support_level>core</support_level>
***/
diff --git a/res/ari/resource_device_states.c b/res/ari/resource_device_states.c
index 020d9301f..c442fa51b 100644
--- a/res/ari/resource_device_states.c
+++ b/res/ari/resource_device_states.c
@@ -24,7 +24,6 @@
*/
/*** MODULEINFO
- <depend type="module">res_stasis_device_state</depend>
<support_level>core</support_level>
***/
diff --git a/res/ari/resource_events.c b/res/ari/resource_events.c
index d81067f15..5a8e89858 100644
--- a/res/ari/resource_events.c
+++ b/res/ari/resource_events.c
@@ -24,7 +24,6 @@
*/
/*** MODULEINFO
- <depend type="module">res_http_websocket</depend>
<support_level>core</support_level>
***/
diff --git a/res/ari/resource_mailboxes.c b/res/ari/resource_mailboxes.c
index 3577e6515..ae0f24978 100644
--- a/res/ari/resource_mailboxes.c
+++ b/res/ari/resource_mailboxes.c
@@ -24,7 +24,6 @@
*/
/*** MODULEINFO
- <depend type="module">res_stasis_mailbox</depend>
<support_level>core</support_level>
***/
diff --git a/res/ari/resource_playbacks.c b/res/ari/resource_playbacks.c
index 57f424c01..fc05a8d03 100644
--- a/res/ari/resource_playbacks.c
+++ b/res/ari/resource_playbacks.c
@@ -24,7 +24,6 @@
*/
/*** MODULEINFO
- <depend type="module">res_stasis_playback</depend>
<support_level>core</support_level>
***/
diff --git a/res/ari/resource_recordings.c b/res/ari/resource_recordings.c
index 39ef65ce3..090f26370 100644
--- a/res/ari/resource_recordings.c
+++ b/res/ari/resource_recordings.c
@@ -24,7 +24,6 @@
*/
/*** MODULEINFO
- <depend type="module">res_stasis_recording</depend>
<support_level>core</support_level>
***/
diff --git a/res/res_agi.c b/res/res_agi.c
index 2d0dc2743..0931c1a07 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -3815,8 +3815,6 @@ int AST_OPTIONAL_API_NAME(ast_agi_register)(struct ast_module *mod, agi_command
AST_RWLIST_WRLOCK(&agi_commands);
AST_LIST_INSERT_TAIL(&agi_commands, cmd, list);
AST_RWLIST_UNLOCK(&agi_commands);
- if (mod != ast_module_info->self)
- ast_module_ref(ast_module_info->self);
ast_verb(2, "AGI Command '%s' registered\n",fullcmd);
return 1;
} else {
@@ -3825,7 +3823,7 @@ int AST_OPTIONAL_API_NAME(ast_agi_register)(struct ast_module *mod, agi_command
}
}
-int AST_OPTIONAL_API_NAME(ast_agi_unregister)(struct ast_module *mod, agi_command *cmd)
+int AST_OPTIONAL_API_NAME(ast_agi_unregister)(agi_command *cmd)
{
struct agi_command *e;
int unregistered = 0;
@@ -3837,8 +3835,6 @@ int AST_OPTIONAL_API_NAME(ast_agi_unregister)(struct ast_module *mod, agi_comman
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&agi_commands, e, list) {
if (cmd == e) {
AST_RWLIST_REMOVE_CURRENT(list);
- if (mod != ast_module_info->self)
- ast_module_unref(ast_module_info->self);
#ifdef AST_XML_DOCS
if (e->docsrc == AST_XML_DOC) {
ast_free((char *) e->summary);
@@ -3885,7 +3881,7 @@ int AST_OPTIONAL_API_NAME(ast_agi_register_multiple)(struct ast_module *mod, str
to fail is if the command is not
registered
*/
- (void) ast_agi_unregister(mod, cmd + x - 1);
+ (void) ast_agi_unregister(cmd + x - 1);
}
return -1;
}
@@ -3893,7 +3889,7 @@ int AST_OPTIONAL_API_NAME(ast_agi_register_multiple)(struct ast_module *mod, str
return 0;
}
-int AST_OPTIONAL_API_NAME(ast_agi_unregister_multiple)(struct ast_module *mod, struct agi_command *cmd, unsigned int len)
+int AST_OPTIONAL_API_NAME(ast_agi_unregister_multiple)(struct agi_command *cmd, unsigned int len)
{
unsigned int i;
int res = 0;
@@ -3903,7 +3899,7 @@ int AST_OPTIONAL_API_NAME(ast_agi_unregister_multiple)(struct ast_module *mod, s
attempts failed... there is no recourse if
any of them do
*/
- res |= ast_agi_unregister(mod, cmd + i);
+ res |= ast_agi_unregister(cmd + i);
}
return res;
@@ -4659,7 +4655,7 @@ AST_TEST_DEFINE(test_agi_null_docs)
}
#endif
- ast_agi_unregister(ast_module_info->self, &noop_command);
+ ast_agi_unregister(&noop_command);
return res;
}
#endif
@@ -4673,7 +4669,7 @@ static int unload_module(void)
STASIS_MESSAGE_TYPE_CLEANUP(agi_async_end_type);
ast_cli_unregister_multiple(cli_agi, ARRAY_LEN(cli_agi));
- ast_agi_unregister_multiple(ast_module_info->self, commands, ARRAY_LEN(commands));
+ ast_agi_unregister_multiple(commands, ARRAY_LEN(commands));
ast_unregister_application(eapp);
ast_unregister_application(deadapp);
ast_manager_unregister("AGI");
@@ -4706,9 +4702,6 @@ static int load_module(void)
return AST_MODULE_LOAD_DECLINE;
}
- /* For Optional API. */
- ast_module_shutdown_ref(AST_MODULE_SELF);
-
return AST_MODULE_LOAD_SUCCESS;
}
diff --git a/res/res_ari.c b/res/res_ari.c
index 6ce25a582..5ffb5833f 100644
--- a/res/res_ari.c
+++ b/res/res_ari.c
@@ -196,7 +196,6 @@ int ast_ari_add_handler(struct stasis_rest_handlers *handler)
ao2_cleanup(root_handler);
ao2_ref(new_handler, +1);
root_handler = new_handler;
- ast_module_ref(ast_module_info->self);
return 0;
}
@@ -222,7 +221,6 @@ int ast_ari_remove_handler(struct stasis_rest_handlers *handler)
memcpy(new_handler, root_handler, sizeof(*new_handler));
for (i = 0, j = 0; i < root_handler->num_children; ++i) {
if (root_handler->children[i] == handler) {
- ast_module_unref(ast_module_info->self);
continue;
}
new_handler->children[j++] = root_handler->children[i];
diff --git a/res/res_ari_applications.c b/res/res_ari_applications.c
index 323bdb39a..fd8a448ce 100644
--- a/res/res_ari_applications.c
+++ b/res/res_ari_applications.c
@@ -493,7 +493,6 @@ static struct stasis_rest_handlers applications = {
static int unload_module(void)
{
ast_ari_remove_handler(&applications);
- stasis_app_unref();
return 0;
}
@@ -501,10 +500,7 @@ static int load_module(void)
{
int res = 0;
- CHECK_ARI_MODULE_LOADED();
-
- stasis_app_ref();
res |= ast_ari_add_handler(&applications);
if (res) {
unload_module();
diff --git a/res/res_ari_asterisk.c b/res/res_ari_asterisk.c
index 9f76f939b..e143a7f6a 100644
--- a/res/res_ari_asterisk.c
+++ b/res/res_ari_asterisk.c
@@ -1214,7 +1214,6 @@ static struct stasis_rest_handlers asterisk = {
static int unload_module(void)
{
ast_ari_remove_handler(&asterisk);
- stasis_app_unref();
return 0;
}
@@ -1222,10 +1221,7 @@ static int load_module(void)
{
int res = 0;
- CHECK_ARI_MODULE_LOADED();
-
- stasis_app_ref();
res |= ast_ari_add_handler(&asterisk);
if (res) {
unload_module();
diff --git a/res/res_ari_bridges.c b/res/res_ari_bridges.c
index 34b9d898c..7ef0f684a 100644
--- a/res/res_ari_bridges.c
+++ b/res/res_ari_bridges.c
@@ -35,6 +35,8 @@
<depend type="module">res_ari</depend>
<depend type="module">res_ari_model</depend>
<depend type="module">res_stasis</depend>
+ <depend type="module">res_stasis_recording</depend>
+ <depend type="module">res_stasis_playback</depend>
<support_level>core</support_level>
***/
@@ -1554,7 +1556,6 @@ static struct stasis_rest_handlers bridges = {
static int unload_module(void)
{
ast_ari_remove_handler(&bridges);
- stasis_app_unref();
return 0;
}
@@ -1562,10 +1563,7 @@ static int load_module(void)
{
int res = 0;
- CHECK_ARI_MODULE_LOADED();
-
- stasis_app_ref();
res |= ast_ari_add_handler(&bridges);
if (res) {
unload_module();
@@ -1579,5 +1577,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Bri
.support_level = AST_MODULE_SUPPORT_CORE,
.load = load_module,
.unload = unload_module,
- .requires = "res_ari,res_ari_model,res_stasis",
+ .requires = "res_ari,res_ari_model,res_stasis,res_stasis_recording,res_stasis_playback",
);
diff --git a/res/res_ari_channels.c b/res/res_ari_channels.c
index 7862c1006..dae146c43 100644
--- a/res/res_ari_channels.c
+++ b/res/res_ari_channels.c
@@ -35,6 +35,10 @@
<depend type="module">res_ari</depend>
<depend type="module">res_ari_model</depend>
<depend type="module">res_stasis</depend>
+ <depend type="module">res_stasis_answer</depend>
+ <depend type="module">res_stasis_playback</depend>
+ <depend type="module">res_stasis_recording</depend>
+ <depend type="module">res_stasis_snoop</depend>
<support_level>core</support_level>
***/
@@ -2844,7 +2848,6 @@ static struct stasis_rest_handlers channels = {
static int unload_module(void)
{
ast_ari_remove_handler(&channels);
- stasis_app_unref();
return 0;
}
@@ -2852,10 +2855,7 @@ static int load_module(void)
{
int res = 0;
- CHECK_ARI_MODULE_LOADED();
-
- stasis_app_ref();
res |= ast_ari_add_handler(&channels);
if (res) {
unload_module();
@@ -2869,5 +2869,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Cha
.support_level = AST_MODULE_SUPPORT_CORE,
.load = load_module,
.unload = unload_module,
- .requires = "res_ari,res_ari_model,res_stasis",
+ .requires = "res_ari,res_ari_model,res_stasis,res_stasis_answer,res_stasis_playback,res_stasis_recording,res_stasis_snoop",
);
diff --git a/res/res_ari_device_states.c b/res/res_ari_device_states.c
index ec8890b1e..12962b68a 100644
--- a/res/res_ari_device_states.c
+++ b/res/res_ari_device_states.c
@@ -35,6 +35,7 @@
<depend type="module">res_ari</depend>
<depend type="module">res_ari_model</depend>
<depend type="module">res_stasis</depend>
+ <depend type="module">res_stasis_device_state</depend>
<support_level>core</support_level>
***/
@@ -324,7 +325,6 @@ static struct stasis_rest_handlers deviceStates = {
static int unload_module(void)
{
ast_ari_remove_handler(&deviceStates);
- stasis_app_unref();
return 0;
}
@@ -332,10 +332,7 @@ static int load_module(void)
{
int res = 0;
- CHECK_ARI_MODULE_LOADED();
-
- stasis_app_ref();
res |= ast_ari_add_handler(&deviceStates);
if (res) {
unload_module();
@@ -349,5 +346,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Dev
.support_level = AST_MODULE_SUPPORT_CORE,
.load = load_module,
.unload = unload_module,
- .requires = "res_ari,res_ari_model,res_stasis",
+ .requires = "res_ari,res_ari_model,res_stasis,res_stasis_device_state",
);
diff --git a/res/res_ari_endpoints.c b/res/res_ari_endpoints.c
index 07197ca97..947da71e2 100644
--- a/res/res_ari_endpoints.c
+++ b/res/res_ari_endpoints.c
@@ -448,7 +448,6 @@ static struct stasis_rest_handlers endpoints = {
static int unload_module(void)
{
ast_ari_remove_handler(&endpoints);
- stasis_app_unref();
return 0;
}
@@ -456,10 +455,7 @@ static int load_module(void)
{
int res = 0;
- CHECK_ARI_MODULE_LOADED();
-
- stasis_app_ref();
res |= ast_ari_add_handler(&endpoints);
if (res) {
unload_module();
diff --git a/res/res_ari_events.c b/res/res_ari_events.c
index f750a5454..c8f28f97b 100644
--- a/res/res_ari_events.c
+++ b/res/res_ari_events.c
@@ -35,6 +35,7 @@
<depend type="module">res_ari</depend>
<depend type="module">res_ari_model</depend>
<depend type="module">res_stasis</depend>
+ <depend type="module">res_http_websocket</depend>
<support_level>core</support_level>
***/
@@ -423,7 +424,6 @@ static int unload_module(void)
ao2_cleanup(events.ws_server);
events.ws_server = NULL;
ast_ari_websocket_events_event_websocket_dtor();
- stasis_app_unref();
return 0;
}
@@ -431,35 +431,29 @@ static int load_module(void)
{
int res = 0;
- CHECK_ARI_MODULE_LOADED();
+ struct ast_websocket_protocol *protocol;
- /* This is scoped to not conflict with CHECK_ARI_MODULE_LOADED */
- {
- struct ast_websocket_protocol *protocol;
-
- if (ast_ari_websocket_events_event_websocket_init() == -1) {
- return AST_MODULE_LOAD_DECLINE;
- }
+ if (ast_ari_websocket_events_event_websocket_init() == -1) {
+ return AST_MODULE_LOAD_DECLINE;
+ }
- events.ws_server = ast_websocket_server_create();
- if (!events.ws_server) {
- ast_ari_websocket_events_event_websocket_dtor();
- return AST_MODULE_LOAD_DECLINE;
- }
+ events.ws_server = ast_websocket_server_create();
+ if (!events.ws_server) {
+ ast_ari_websocket_events_event_websocket_dtor();
+ return AST_MODULE_LOAD_DECLINE;
+ }
- protocol = ast_websocket_sub_protocol_alloc("ari");
- if (!protocol) {
- ao2_ref(events.ws_server, -1);
- events.ws_server = NULL;
- ast_ari_websocket_events_event_websocket_dtor();
- return AST_MODULE_LOAD_DECLINE;
- }
- protocol->session_attempted = ast_ari_events_event_websocket_ws_attempted_cb;
- protocol->session_established = ast_ari_events_event_websocket_ws_established_cb;
- res |= ast_websocket_server_add_protocol2(events.ws_server, protocol);
+ protocol = ast_websocket_sub_protocol_alloc("ari");
+ if (!protocol) {
+ ao2_ref(events.ws_server, -1);
+ events.ws_server = NULL;
+ ast_ari_websocket_events_event_websocket_dtor();
+ return AST_MODULE_LOAD_DECLINE;
}
+ protocol->session_attempted = ast_ari_events_event_websocket_ws_attempted_cb;
+ protocol->session_established = ast_ari_events_event_websocket_ws_established_cb;
+ res |= ast_websocket_server_add_protocol2(events.ws_server, protocol);
- stasis_app_ref();
res |= ast_ari_add_handler(&events);
if (res) {
unload_module();
@@ -473,5 +467,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Web
.support_level = AST_MODULE_SUPPORT_CORE,
.load = load_module,
.unload = unload_module,
- .requires = "res_ari,res_ari_model,res_stasis",
+ .requires = "res_ari,res_ari_model,res_stasis,res_http_websocket",
);
diff --git a/res/res_ari_mailboxes.c b/res/res_ari_mailboxes.c
index 6469f936e..e25a7bc3d 100644
--- a/res/res_ari_mailboxes.c
+++ b/res/res_ari_mailboxes.c
@@ -35,6 +35,7 @@
<depend type="module">res_ari</depend>
<depend type="module">res_ari_model</depend>
<depend type="module">res_stasis</depend>
+ <depend type="module">res_stasis_mailbox</depend>
<support_level>core</support_level>
***/
@@ -330,7 +331,6 @@ static struct stasis_rest_handlers mailboxes = {
static int unload_module(void)
{
ast_ari_remove_handler(&mailboxes);
- stasis_app_unref();
return 0;
}
@@ -338,10 +338,7 @@ static int load_module(void)
{
int res = 0;
- CHECK_ARI_MODULE_LOADED();
-
- stasis_app_ref();
res |= ast_ari_add_handler(&mailboxes);
if (res) {
unload_module();
@@ -355,5 +352,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Mai
.support_level = AST_MODULE_SUPPORT_CORE,
.load = load_module,
.unload = unload_module,
- .requires = "res_ari,res_ari_model,res_stasis",
+ .requires = "res_ari,res_ari_model,res_stasis,res_stasis_mailbox",
);
diff --git a/res/res_ari_playbacks.c b/res/res_ari_playbacks.c
index 0148a7400..5fbfcf165 100644
--- a/res/res_ari_playbacks.c
+++ b/res/res_ari_playbacks.c
@@ -35,6 +35,7 @@
<depend type="module">res_ari</depend>
<depend type="module">res_ari_model</depend>
<depend type="module">res_stasis</depend>
+ <depend type="module">res_stasis_playback</depend>
<support_level>core</support_level>
***/
@@ -282,7 +283,6 @@ static struct stasis_rest_handlers playbacks = {
static int unload_module(void)
{
ast_ari_remove_handler(&playbacks);
- stasis_app_unref();
return 0;
}
@@ -290,10 +290,7 @@ static int load_module(void)
{
int res = 0;
- CHECK_ARI_MODULE_LOADED();
-
- stasis_app_ref();
res |= ast_ari_add_handler(&playbacks);
if (res) {
unload_module();
@@ -307,5 +304,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Pla
.support_level = AST_MODULE_SUPPORT_CORE,
.load = load_module,
.unload = unload_module,
- .requires = "res_ari,res_ari_model,res_stasis",
+ .requires = "res_ari,res_ari_model,res_stasis,res_stasis_playback",
);
diff --git a/res/res_ari_recordings.c b/res/res_ari_recordings.c
index 531ff6574..6487f3e15 100644
--- a/res/res_ari_recordings.c
+++ b/res/res_ari_recordings.c
@@ -35,6 +35,7 @@
<depend type="module">res_ari</depend>
<depend type="module">res_ari_model</depend>
<depend type="module">res_stasis</depend>
+ <depend type="module">res_stasis_recording</depend>
<support_level>core</support_level>
***/
@@ -866,7 +867,6 @@ static struct stasis_rest_handlers recordings = {
static int unload_module(void)
{
ast_ari_remove_handler(&recordings);
- stasis_app_unref();
return 0;
}
@@ -874,10 +874,7 @@ static int load_module(void)
{
int res = 0;
- CHECK_ARI_MODULE_LOADED();
-
- stasis_app_ref();
res |= ast_ari_add_handler(&recordings);
if (res) {
unload_module();
@@ -891,5 +888,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Rec
.support_level = AST_MODULE_SUPPORT_CORE,
.load = load_module,
.unload = unload_module,
- .requires = "res_ari,res_ari_model,res_stasis",
+ .requires = "res_ari,res_ari_model,res_stasis,res_stasis_recording",
);
diff --git a/res/res_ari_sounds.c b/res/res_ari_sounds.c
index 5c27ebd92..b9c9bdfac 100644
--- a/res/res_ari_sounds.c
+++ b/res/res_ari_sounds.c
@@ -212,7 +212,6 @@ static struct stasis_rest_handlers sounds = {
static int unload_module(void)
{
ast_ari_remove_handler(&sounds);
- stasis_app_unref();
return 0;
}
@@ -220,10 +219,7 @@ static int load_module(void)
{
int res = 0;
- CHECK_ARI_MODULE_LOADED();
-
- stasis_app_ref();
res |= ast_ari_add_handler(&sounds);
if (res) {
unload_module();
diff --git a/res/res_config_curl.c b/res/res_config_curl.c
index 213209720..03f0338cc 100644
--- a/res/res_config_curl.c
+++ b/res/res_config_curl.c
@@ -637,20 +637,6 @@ static int unload_module(void)
static int load_module(void)
{
- if (!ast_module_check("res_curl.so")) {
- if (ast_load_resource("res_curl.so") != AST_MODULE_LOAD_SUCCESS) {
- ast_log(LOG_ERROR, "Cannot load res_curl, so res_config_curl cannot be loaded\n");
- return AST_MODULE_LOAD_DECLINE;
- }
- }
-
- if (!ast_module_check("func_curl.so")) {
- if (ast_load_resource("func_curl.so") != AST_MODULE_LOAD_SUCCESS) {
- ast_log(LOG_ERROR, "Cannot load func_curl, so res_config_curl cannot be loaded\n");
- return AST_MODULE_LOAD_DECLINE;
- }
- }
-
reload_module();
ast_config_engine_register(&curl_engine);
@@ -664,4 +650,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Realtime Curl configu
.unload = unload_module,
.reload = reload_module,
.load_pri = AST_MODPRI_REALTIME_DRIVER,
+ .requires = "res_curl,func_curl",
);
diff --git a/res/res_crypto.c b/res/res_crypto.c
index 8f97ce9f8..4f8f2cb6e 100644
--- a/res/res_crypto.c
+++ b/res/res_crypto.c
@@ -651,8 +651,6 @@ static int load_module(void)
crypto_load(-1, -1);
}
- /* This prevents dlclose from ever running, but allows CLI cleanup at shutdown. */
- ast_module_shutdown_ref(ast_module_info->self);
return AST_MODULE_LOAD_SUCCESS;
}
@@ -663,7 +661,6 @@ static int unload_module(void)
return 0;
}
-/* needs usecount semantics defined */
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "Cryptographic Digital Signatures",
.support_level = AST_MODULE_SUPPORT_CORE,
.load = load_module,
diff --git a/res/res_curl.c b/res/res_curl.c
index e0f753cc3..3dc7c2f03 100644
--- a/res/res_curl.c
+++ b/res/res_curl.c
@@ -46,33 +46,11 @@
#include "asterisk/module.h"
-static const char *dependents[] = {
- "func_curl.so",
- "res_config_curl.so",
- "res_http_media_cache.so",
-};
-
static int unload_module(void)
{
- int res = 0;
- size_t i;
-
- /* If the dependent modules are still in memory, forbid unload */
- for (i = 0; i < ARRAY_LEN(dependents); i++) {
- if (ast_module_check(dependents[i])) {
- if (!ast_shutting_down()) {
- ast_log(LOG_WARNING, "%s (dependent module) is still loaded. Cannot unload res_curl.so\n", dependents[i]);
- }
- res = -1;
- }
- }
-
- if (res)
- return -1;
-
curl_global_cleanup();
- return res;
+ return 0;
}
static int load_module(void)
diff --git a/res/res_fax.c b/res/res_fax.c
index 4be5aee75..315f0003b 100644
--- a/res/res_fax.c
+++ b/res/res_fax.c
@@ -978,7 +978,6 @@ int ast_fax_tech_register(struct ast_fax_tech *tech)
AST_RWLIST_WRLOCK(&faxmodules);
AST_RWLIST_INSERT_TAIL(&faxmodules, fax, list);
AST_RWLIST_UNLOCK(&faxmodules);
- ast_module_ref(ast_module_info->self);
ast_verb(3, "Registered handler for '%s' (%s)\n", fax->tech->type, fax->tech->description);
@@ -998,7 +997,6 @@ void ast_fax_tech_unregister(struct ast_fax_tech *tech)
continue;
}
AST_RWLIST_REMOVE_CURRENT(list);
- ast_module_unref(ast_module_info->self);
ast_free(fax);
ast_verb(4, "Unregistered FAX module type '%s'\n", tech->type);
break;
diff --git a/res/res_hep_pjsip.c b/res/res_hep_pjsip.c
index ff0267501..be2f6eab0 100644
--- a/res/res_hep_pjsip.c
+++ b/res/res_hep_pjsip.c
@@ -232,10 +232,8 @@ static pjsip_module logging_module = {
static int load_module(void)
{
- CHECK_PJSIP_MODULE_LOADED();
-
- if (!ast_module_check("res_hep.so") || !hepv3_is_loaded()) {
- ast_log(AST_LOG_WARNING, "res_hep is not loaded or running; declining module load\n");
+ if (!hepv3_is_loaded()) {
+ ast_log(AST_LOG_WARNING, "res_hep is disabled; declining module load\n");
return AST_MODULE_LOAD_DECLINE;
}
diff --git a/res/res_hep_rtcp.c b/res/res_hep_rtcp.c
index 199c8164d..c3abbc164 100644
--- a/res/res_hep_rtcp.c
+++ b/res/res_hep_rtcp.c
@@ -157,8 +157,8 @@ static void rtp_topic_handler(void *data, struct stasis_subscription *sub, struc
static int load_module(void)
{
- if (!ast_module_check("res_hep.so") || !hepv3_is_loaded()) {
- ast_log(AST_LOG_WARNING, "res_hep is not loaded or running; declining module load\n");
+ if (!hepv3_is_loaded()) {
+ ast_log(AST_LOG_WARNING, "res_hep is disabled; declining module load\n");
return AST_MODULE_LOAD_DECLINE;
}
diff --git a/res/res_http_media_cache.c b/res/res_http_media_cache.c
index 918686e8a..eba7ecc61 100644
--- a/res/res_http_media_cache.c
+++ b/res/res_http_media_cache.c
@@ -441,4 +441,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "HTTP Media Cache Backend
.support_level = AST_MODULE_SUPPORT_CORE,
.load = load_module,
.unload = unload_module,
+ .requires = "res_curl",
);
diff --git a/res/res_http_websocket.c b/res/res_http_websocket.c
index 86a154787..bcad1c39c 100644
--- a/res/res_http_websocket.c
+++ b/res/res_http_websocket.c
@@ -131,24 +131,18 @@ struct ast_websocket_server {
struct ao2_container *protocols; /*!< Container for registered protocols */
};
-static void websocket_server_internal_dtor(void *obj)
+static void websocket_server_dtor(void *obj)
{
struct ast_websocket_server *server = obj;
ao2_cleanup(server->protocols);
server->protocols = NULL;
}
-static void websocket_server_dtor(void *obj)
-{
- websocket_server_internal_dtor(obj);
- ast_module_unref(ast_module_info->self);
-}
-
-static struct ast_websocket_server *websocket_server_create_impl(void (*dtor)(void *))
+static struct ast_websocket_server *websocket_server_create_impl(void)
{
RAII_VAR(struct ast_websocket_server *, server, NULL, ao2_cleanup);
- server = ao2_alloc(sizeof(*server), dtor);
+ server = ao2_alloc(sizeof(*server), websocket_server_dtor);
if (!server) {
return NULL;
}
@@ -164,13 +158,12 @@ static struct ast_websocket_server *websocket_server_create_impl(void (*dtor)(vo
static struct ast_websocket_server *websocket_server_internal_create(void)
{
- return websocket_server_create_impl(websocket_server_internal_dtor);
+ return websocket_server_create_impl();
}
struct ast_websocket_server *AST_OPTIONAL_API_NAME(ast_websocket_server_create)(void)
{
- ast_module_ref(ast_module_info->self);
- return websocket_server_create_impl(websocket_server_dtor);
+ return websocket_server_create_impl();
}
/*! \brief Destructor function for sessions */
@@ -997,11 +990,7 @@ static int websocket_add_protocol_internal(const char *name, ast_websocket_callb
int AST_OPTIONAL_API_NAME(ast_websocket_add_protocol)(const char *name, ast_websocket_callback callback)
{
- int res = websocket_add_protocol_internal(name, callback);
- if (res == 0) {
- ast_module_ref(ast_module_info->self);
- }
- return res;
+ return websocket_add_protocol_internal(name, callback);
}
int AST_OPTIONAL_API_NAME(ast_websocket_add_protocol2)(struct ast_websocket_protocol *protocol)
@@ -1016,7 +1005,6 @@ int AST_OPTIONAL_API_NAME(ast_websocket_add_protocol2)(struct ast_websocket_prot
return -1;
}
- ast_module_ref(ast_module_info->self);
return 0;
}
@@ -1031,11 +1019,7 @@ static int websocket_remove_protocol_internal(const char *name, ast_websocket_ca
int AST_OPTIONAL_API_NAME(ast_websocket_remove_protocol)(const char *name, ast_websocket_callback callback)
{
- int res = websocket_remove_protocol_internal(name, callback);
- if (res == 0) {
- ast_module_unref(ast_module_info->self);
- }
- return res;
+ return websocket_remove_protocol_internal(name, callback);
}
/*! \brief Parse the given uri into a path and remote address.
@@ -1457,9 +1441,6 @@ static int load_module(void)
ast_http_uri_link(&websocketuri);
websocket_add_protocol_internal("echo", websocket_echo_callback);
- /* For Optional API. */
- ast_module_shutdown_ref(AST_MODULE_SELF);
-
return 0;
}
diff --git a/res/res_monitor.c b/res/res_monitor.c
index 9dcbdbe62..a8631dcb7 100644
--- a/res/res_monitor.c
+++ b/res/res_monitor.c
@@ -985,9 +985,6 @@ static int load_module(void)
ast_manager_register_xml("PauseMonitor", EVENT_FLAG_CALL, pause_monitor_action);
ast_manager_register_xml("UnpauseMonitor", EVENT_FLAG_CALL, unpause_monitor_action);
- /* For Optional API. */
- ast_module_shutdown_ref(AST_MODULE_SELF);
-
return AST_MODULE_LOAD_SUCCESS;
}
@@ -1013,4 +1010,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_
.load = load_module,
.unload = unload_module,
.load_pri = AST_MODPRI_CHANNEL_DEPEND,
+ .optional_modules = "func_periodic_hook",
);
diff --git a/res/res_mwi_external.c b/res/res_mwi_external.c
index d79799196..82c74b990 100644
--- a/res/res_mwi_external.c
+++ b/res/res_mwi_external.c
@@ -81,16 +81,6 @@ struct ast_mwi_mailbox_object {
static struct ast_sorcery *mwi_sorcery;
-void ast_mwi_external_ref(void)
-{
- ast_module_ref(ast_module_info->self);
-}
-
-void ast_mwi_external_unref(void)
-{
- ast_module_unref(ast_module_info->self);
-}
-
/*!
* \internal
* \brief Post an update event to the MWI counts.
diff --git a/res/res_mwi_external_ami.c b/res/res_mwi_external_ami.c
index 8639fad40..e4d5054e2 100644
--- a/res/res_mwi_external_ami.c
+++ b/res/res_mwi_external_ami.c
@@ -342,8 +342,6 @@ static int unload_module(void)
ast_manager_unregister("MWIDelete");
ast_manager_unregister("MWIUpdate");
- /* Must be done last */
- ast_mwi_external_unref();
return 0;
}
@@ -351,9 +349,6 @@ static int load_module(void)
{
int res;
- /* Must be done first */
- ast_mwi_external_ref();
-
res = 0;
res |= ast_manager_register_xml("MWIGet", EVENT_FLAG_CALL | EVENT_FLAG_REPORTING, mwi_mailbox_get);
res |= ast_manager_register_xml("MWIDelete", EVENT_FLAG_CALL, mwi_mailbox_delete);
diff --git a/res/res_pjproject.c b/res/res_pjproject.c
index 6137898a3..f506a62fd 100644
--- a/res/res_pjproject.c
+++ b/res/res_pjproject.c
@@ -280,16 +280,6 @@ void ast_pjproject_log_intercept_end(void)
ast_mutex_unlock(&pjproject_log_intercept_lock);
}
-void ast_pjproject_ref(void)
-{
- ast_module_ref(ast_module_info->self);
-}
-
-void ast_pjproject_unref(void)
-{
- ast_module_unref(ast_module_info->self);
-}
-
static char *handle_pjproject_show_buildopts(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
int i;
diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index 05f92f268..310ff20bc 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -66,7 +66,7 @@
It contains the core SIP related options only, endpoints are <emphasis>NOT</emphasis>
dialable entries of their own. Communication with another SIP device is
accomplished via Addresses of Record (AoRs) which have one or more
- contacts assicated with them. Endpoints <emphasis>NOT</emphasis> configured to
+ contacts associated with them. Endpoints <emphasis>NOT</emphasis> configured to
use a <literal>transport</literal> will default to first transport found
in <filename>pjsip.conf</filename> that matches its type.
</para>
@@ -449,7 +449,7 @@
<configOption name="timers_min_se" default="90">
<synopsis>Minimum session timers expiration period</synopsis>
<description><para>
- Minimium session timer expiration period. Time in seconds.
+ Minimum session timer expiration period. Time in seconds.
</para></description>
</configOption>
<configOption name="timers" default="yes">
@@ -467,7 +467,7 @@
<configOption name="timers_sess_expires" default="1800">
<synopsis>Maximum session timer expiration period</synopsis>
<description><para>
- Maximium session timer expiration period. Time in seconds.
+ Maximum session timer expiration period. Time in seconds.
</para></description>
</configOption>
<configOption name="transport">
@@ -509,7 +509,7 @@
<synopsis>Must be of type 'endpoint'.</synopsis>
</configOption>
<configOption name="use_ptime" default="no">
- <synopsis>Use Endpoint's requested packetisation interval</synopsis>
+ <synopsis>Use Endpoint's requested packetization interval</synopsis>
</configOption>
<configOption name="use_avpf" default="no">
<synopsis>Determines whether res_pjsip will use and enforce usage of AVPF for this
@@ -647,7 +647,7 @@
Forward error correction should be used.
</para></enum>
<enum name="redundancy"><para>
- Redundacy error correction should be used.
+ Redundancy error correction should be used.
</para></enum>
</enumlist>
</description>
@@ -1111,7 +1111,7 @@
<description><para>Only used when auth_type is <literal>md5</literal>.</para></description>
</configOption>
<configOption name="password">
- <synopsis>PlainText password used for authentication.</synopsis>
+ <synopsis>Plain text password used for authentication.</synopsis>
<description><para>Only used when auth_type is <literal>userpass</literal>.</para></description>
</configOption>
<configOption name="realm">
@@ -1316,7 +1316,7 @@
</description>
</configOption>
<configOption name="symmetric_transport" default="no">
- <synopsis>Use the same transport for outgoing reqests as incoming ones.</synopsis>
+ <synopsis>Use the same transport for outgoing requests as incoming ones.</synopsis>
<description>
<para>When a request from a dynamic contact
comes in on a transport with this option set to 'yes',
@@ -1361,7 +1361,7 @@
<configOption name="qualify_timeout" default="3.0">
<synopsis>Timeout for qualify</synopsis>
<description><para>
- If the contact doesn't repond to the OPTIONS request before the timeout,
+ If the contact doesn't respond to the OPTIONS request before the timeout,
the contact is marked unavailable.
If <literal>0</literal> no timeout. Time in fractional seconds.
</para></description>
@@ -1445,8 +1445,8 @@
<literal>endpoint</literal> for calls.
</para><para>
This can be used as another way of grouping a list of contacts to dial
- rather than specifing them each directly when dialing via the dialplan.
- This must be used in conjuction with the <literal>PJSIP_DIAL_CONTACTS</literal>.
+ rather than specifying them each directly when dialing via the dialplan.
+ This must be used in conjunction with the <literal>PJSIP_DIAL_CONTACTS</literal>.
</para><para>
Registrations: For Asterisk to match an inbound registration to an endpoint,
the AoR object name must match the user portion of the SIP URI in the "To:"
@@ -1486,7 +1486,7 @@
<configOption name="maximum_expiration" default="7200">
<synopsis>Maximum time to keep an AoR</synopsis>
<description><para>
- Maximium time to keep a peer with explicit expiration. Time in seconds.
+ Maximum time to keep a peer with explicit expiration. Time in seconds.
</para></description>
</configOption>
<configOption name="max_contacts" default="0">
@@ -1560,7 +1560,7 @@
<configOption name="qualify_timeout" default="3.0">
<synopsis>Timeout for qualify</synopsis>
<description><para>
- If the contact doesn't repond to the OPTIONS request before the timeout,
+ If the contact doesn't respond to the OPTIONS request before the timeout,
the contact is marked unavailable.
If <literal>0</literal> no timeout. Time in fractional seconds.
</para></description>
@@ -1659,7 +1659,7 @@
<configOption name="disable_multi_domain" default="no">
<synopsis>Disable Multi Domain support</synopsis>
<description><para>
- If disabled it can improve realtime performace by reducing number of database requsts.
+ If disabled it can improve realtime performance by reducing the number of database requests.
</para></description>
</configOption>
<configOption name="max_initial_qualify_time" default="0">
@@ -1785,7 +1785,7 @@
in the user field of a SIP URI then the field is truncated
at the first semicolon. This effectively makes the semicolon
a non-usable character for PJSIP endpoint names, extensions,
- and AORs. This can be useful for improving compatability with
+ and AORs. This can be useful for improving compatibility with
an ITSP that likes to use user options for whatever reason.
</para>
<example title="Sample SIP URI">
@@ -2716,7 +2716,7 @@ static pj_sockaddr host_ip_ipv6;
/*! Local host address for IPv6 (string form) */
static char host_ip_ipv6_string[PJ_INET6_ADDRSTRLEN];
-static int register_service_noref(void *data)
+static int register_service(void *data)
{
pjsip_module **module = data;
if (!ast_pjsip_endpoint) {
@@ -2731,23 +2731,12 @@ static int register_service_noref(void *data)
return 0;
}
-int internal_sip_register_service(pjsip_module *module)
+int ast_sip_register_service(pjsip_module *module)
{
- return ast_sip_push_task_synchronous(NULL, register_service_noref, &module);
+ return ast_sip_push_task_synchronous(NULL, register_service, &module);
}
-int __ast_sip_register_service(pjsip_module *module, const char *file, int line, const char *func)
-{
- int res;
-
- if (!(res = ast_sip_push_task_synchronous(NULL, register_service_noref, &module))) {
- __ast_module_ref(ast_module_info->self, file, line, func);
- }
-
- return res;
-}
-
-static int unregister_service_noref(void *data)
+static int unregister_service(void *data)
{
pjsip_module **module = data;
if (!ast_pjsip_endpoint) {
@@ -2758,16 +2747,9 @@ static int unregister_service_noref(void *data)
return 0;
}
-int internal_sip_unregister_service(pjsip_module *module)
+void ast_sip_unregister_service(pjsip_module *module)
{
- return ast_sip_push_task_synchronous(NULL, unregister_service_noref, &module);
-}
-
-void __ast_sip_unregister_service(pjsip_module *module, const char *file, int line, const char *func)
-{
- if (!ast_sip_push_task_synchronous(NULL, unregister_service_noref, &module)) {
- __ast_module_unref(ast_module_info->self, file, line, func);
- }
+ ast_sip_push_task_synchronous(NULL, unregister_service, &module);
}
static struct ast_sip_authenticator *registered_authenticator;
@@ -2780,7 +2762,7 @@ int ast_sip_register_authenticator(struct ast_sip_authenticator *auth)
}
registered_authenticator = auth;
ast_debug(1, "Registered SIP authenticator module %p\n", auth);
- ast_module_ref(ast_module_info->self);
+
return 0;
}
@@ -2793,7 +2775,6 @@ void ast_sip_unregister_authenticator(struct ast_sip_authenticator *auth)
}
registered_authenticator = NULL;
ast_debug(1, "Unregistered SIP authenticator %p\n", auth);
- ast_module_unref(ast_module_info->self);
}
int ast_sip_requires_authentication(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)
@@ -2826,7 +2807,7 @@ int ast_sip_register_outbound_authenticator(struct ast_sip_outbound_authenticato
}
registered_outbound_authenticator = auth;
ast_debug(1, "Registered SIP outbound authenticator module %p\n", auth);
- ast_module_ref(ast_module_info->self);
+
return 0;
}
@@ -2839,7 +2820,6 @@ void ast_sip_unregister_outbound_authenticator(struct ast_sip_outbound_authentic
}
registered_outbound_authenticator = NULL;
ast_debug(1, "Unregistered SIP outbound authenticator %p\n", auth);
- ast_module_unref(ast_module_info->self);
}
int ast_sip_create_request_with_auth(const struct ast_sip_auth_vector *auths, pjsip_rx_data *challenge,
@@ -2881,7 +2861,6 @@ int ast_sip_register_endpoint_identifier_with_name(struct ast_sip_endpoint_ident
if (ast_strlen_zero(name)) {
/* if an identifier has no name then place in front */
AST_RWLIST_INSERT_HEAD(&endpoint_identifiers, id_list_item, list);
- ast_module_ref(ast_module_info->self);
return 0;
}
@@ -2891,7 +2870,6 @@ int ast_sip_register_endpoint_identifier_with_name(struct ast_sip_endpoint_ident
if (ast_strlen_zero(identifier_order)) {
id_list_item->priority = UINT_MAX;
AST_RWLIST_INSERT_TAIL(&endpoint_identifiers, id_list_item, list);
- ast_module_ref(ast_module_info->self);
ast_free(identifier_order);
return 0;
}
@@ -2919,7 +2897,6 @@ int ast_sip_register_endpoint_identifier_with_name(struct ast_sip_endpoint_ident
/* if not in the endpoint_identifier_order list then consider it less in
priority and add it to the end */
AST_RWLIST_INSERT_TAIL(&endpoint_identifiers, id_list_item, list);
- ast_module_ref(ast_module_info->self);
ast_free(identifier_order);
return 0;
}
@@ -2937,7 +2914,6 @@ int ast_sip_register_endpoint_identifier_with_name(struct ast_sip_endpoint_ident
}
AST_RWLIST_TRAVERSE_SAFE_END;
- ast_module_ref(ast_module_info->self);
ast_free(identifier_order);
return 0;
}
@@ -2956,7 +2932,6 @@ void ast_sip_unregister_endpoint_identifier(struct ast_sip_endpoint_identifier *
AST_RWLIST_REMOVE_CURRENT(list);
ast_free(iter);
ast_debug(1, "Unregistered endpoint identifier %p\n", identifier);
- ast_module_unref(ast_module_info->self);
break;
}
}
@@ -3099,23 +3074,17 @@ static struct ast_cli_entry cli_commands[] = {
AST_RWLIST_HEAD_STATIC(endpoint_formatters, ast_sip_endpoint_formatter);
-void internal_sip_register_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)
+void ast_sip_register_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)
{
SCOPED_LOCK(lock, &endpoint_formatters, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);
AST_RWLIST_INSERT_TAIL(&endpoint_formatters, obj, next);
}
-int ast_sip_register_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)
-{
- internal_sip_register_endpoint_formatter(obj);
- ast_module_ref(ast_module_info->self);
- return 0;
-}
-
-int internal_sip_unregister_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)
+void ast_sip_unregister_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)
{
struct ast_sip_endpoint_formatter *i;
SCOPED_LOCK(lock, &endpoint_formatters, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);
+
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&endpoint_formatters, i, next) {
if (i == obj) {
AST_RWLIST_REMOVE_CURRENT(next);
@@ -3123,14 +3092,6 @@ int internal_sip_unregister_endpoint_formatter(struct ast_sip_endpoint_formatter
}
}
AST_RWLIST_TRAVERSE_SAFE_END;
- return i == obj ? 0 : -1;
-}
-
-void ast_sip_unregister_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)
-{
- if (!internal_sip_unregister_endpoint_formatter(obj)) {
- ast_module_unref(ast_module_info->self);
- }
}
int ast_sip_format_endpoint_ami(struct ast_sip_endpoint *endpoint,
@@ -3157,6 +3118,45 @@ pjsip_endpoint *ast_sip_get_pjsip_endpoint(void)
return ast_pjsip_endpoint;
}
+int ast_sip_will_uri_survive_restart(pjsip_sip_uri *uri, struct ast_sip_endpoint *endpoint,
+ pjsip_rx_data *rdata)
+{
+ pj_str_t host_name;
+ int result = 1;
+
+ /* Determine if the contact cannot survive a restart/boot. */
+ if (uri->port == rdata->pkt_info.src_port
+ && !pj_strcmp(&uri->host,
+ pj_cstr(&host_name, rdata->pkt_info.src_name))
+ /* We have already checked if the URI scheme is sip: or sips: */
+ && PJSIP_TRANSPORT_IS_RELIABLE(rdata->tp_info.transport)) {
+ pj_str_t type_name;
+
+ /* Determine the transport parameter value */
+ if (!strcasecmp("WSS", rdata->tp_info.transport->type_name)) {
+ /* WSS is special, as it needs to be ws. */
+ pj_cstr(&type_name, "ws");
+ } else {
+ pj_cstr(&type_name, rdata->tp_info.transport->type_name);
+ }
+
+ if (!pj_stricmp(&uri->transport_param, &type_name)
+ && (endpoint->nat.rewrite_contact
+ /* Websockets are always rewritten */
+ || !pj_stricmp(&uri->transport_param,
+ pj_cstr(&type_name, "ws")))) {
+ /*
+ * The contact was rewritten to the reliable transport's
+ * source address. Disconnecting the transport for any
+ * reason invalidates the contact.
+ */
+ result = 0;
+ }
+ }
+
+ return result;
+}
+
int ast_sip_get_transport_name(const struct ast_sip_endpoint *endpoint,
pjsip_sip_uri *sip_uri, char *buf, size_t buf_len)
{
@@ -3817,7 +3817,7 @@ int ast_sip_create_request(const char *method, struct pjsip_dialog *dlg,
AST_RWLIST_HEAD_STATIC(supplements, ast_sip_supplement);
-void internal_sip_register_supplement(struct ast_sip_supplement *supplement)
+void ast_sip_register_supplement(struct ast_sip_supplement *supplement)
{
struct ast_sip_supplement *iter;
int inserted = 0;
@@ -3837,39 +3837,18 @@ void internal_sip_register_supplement(struct ast_sip_supplement *supplement)
}
}
-int __ast_sip_register_supplement(struct ast_sip_supplement *supplement,
- const char *file, int line, const char *func)
-{
- internal_sip_register_supplement(supplement);
- __ast_module_ref(ast_module_info->self, file, line, func);
-
- return 0;
-}
-
-int internal_sip_unregister_supplement(struct ast_sip_supplement *supplement)
+void ast_sip_unregister_supplement(struct ast_sip_supplement *supplement)
{
struct ast_sip_supplement *iter;
SCOPED_LOCK(lock, &supplements, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);
- int res = -1;
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&supplements, iter, next) {
if (supplement == iter) {
AST_RWLIST_REMOVE_CURRENT(next);
- res = 0;
break;
}
}
AST_RWLIST_TRAVERSE_SAFE_END;
-
- return res;
-}
-
-void __ast_sip_unregister_supplement(struct ast_sip_supplement *supplement,
- const char *file, int line, const char *func)
-{
- if (!internal_sip_unregister_supplement(supplement)) {
- __ast_module_unref(ast_module_info->self, file, line, func);
- }
}
static int send_in_dialog_request(pjsip_tx_data *tdata, struct pjsip_dialog *dlg)
@@ -4999,7 +4978,7 @@ static int unload_pjsip(void *data)
ast_res_pjsip_destroy_configuration();
ast_sip_destroy_system();
ast_sip_destroy_global_headers();
- internal_sip_unregister_service(&supplement_module);
+ ast_sip_unregister_service(&supplement_module);
ast_sip_destroy_transport_events();
}
@@ -5099,8 +5078,6 @@ static int load_module(void)
{
struct ast_threadpool_options options;
- CHECK_PJPROJECT_MODULE_LOADED();
-
/* pjproject and config_system need to be initialized before all else */
if (pj_init() != PJ_SUCCESS) {
return AST_MODULE_LOAD_DECLINE;
@@ -5166,7 +5143,7 @@ static int load_module(void)
goto error;
}
- if (internal_sip_register_service(&supplement_module)) {
+ if (ast_sip_register_service(&supplement_module)) {
ast_log(LOG_ERROR, "Failed to initialize supplement hooks. Aborting load\n");
goto error;
}
@@ -5183,8 +5160,6 @@ static int load_module(void)
AST_TEST_REGISTER(xml_sanitization_end_null);
AST_TEST_REGISTER(xml_sanitization_exceeds_buffer);
- ast_pjproject_ref();
-
return AST_MODULE_LOAD_SUCCESS;
error:
@@ -5226,8 +5201,6 @@ static int unload_module(void)
serializer_pool_shutdown();
ast_threadpool_shutdown(sip_threadpool);
- ast_pjproject_unref();
-
return 0;
}
@@ -5238,4 +5211,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_
.reload = reload_module,
.load_pri = AST_MODPRI_CHANNEL_DEPEND - 5,
.requires = "res_pjproject",
+ .optional_modules = "res_statsd",
);
diff --git a/res/res_pjsip/config_auth.c b/res/res_pjsip/config_auth.c
index 47326815b..b1bf9c422 100644
--- a/res/res_pjsip/config_auth.c
+++ b/res/res_pjsip/config_auth.c
@@ -374,7 +374,7 @@ int ast_sip_initialize_sorcery_auth(void)
ast_sorcery_object_field_register_custom(sorcery, SIP_SORCERY_AUTH_TYPE, "auth_type",
"userpass", auth_type_handler, auth_type_to_str, NULL, 0, 0);
- internal_sip_register_endpoint_formatter(&endpoint_auth_formatter);
+ ast_sip_register_endpoint_formatter(&endpoint_auth_formatter);
cli_formatter = ao2_alloc(sizeof(struct ast_sip_cli_formatter_entry), NULL);
if (!cli_formatter) {
@@ -403,7 +403,7 @@ int ast_sip_destroy_sorcery_auth(void)
{
ast_cli_unregister_multiple(cli_commands, ARRAY_LEN(cli_commands));
ast_sip_unregister_cli_formatter(cli_formatter);
- internal_sip_unregister_endpoint_formatter(&endpoint_auth_formatter);
+ ast_sip_unregister_endpoint_formatter(&endpoint_auth_formatter);
ast_manager_unregister("PJSIPShowAuths");
diff --git a/res/res_pjsip/config_transport.c b/res/res_pjsip/config_transport.c
index 63bf11812..15c03769b 100644
--- a/res/res_pjsip/config_transport.c
+++ b/res/res_pjsip/config_transport.c
@@ -30,6 +30,7 @@
#include "asterisk/acl.h"
#include "asterisk/utils.h"
#include "include/res_pjsip_private.h"
+/* We're only using a #define from http_websocket.h, no OPTIONAL_API symbols are used. */
#include "asterisk/http_websocket.h"
#define MAX_POINTER_STRING 33
@@ -1435,7 +1436,7 @@ int ast_sip_initialize_sorcery_transport(void)
ast_sorcery_object_field_register(sorcery, "transport", "allow_reload", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_transport, allow_reload));
ast_sorcery_object_field_register(sorcery, "transport", "symmetric_transport", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_transport, symmetric_transport));
- internal_sip_register_endpoint_formatter(&endpoint_transport_formatter);
+ ast_sip_register_endpoint_formatter(&endpoint_transport_formatter);
cli_formatter = ao2_alloc(sizeof(struct ast_sip_cli_formatter_entry), NULL);
if (!cli_formatter) {
@@ -1465,7 +1466,7 @@ int ast_sip_destroy_sorcery_transport(void)
ast_cli_unregister_multiple(cli_commands, ARRAY_LEN(cli_commands));
ast_sip_unregister_cli_formatter(cli_formatter);
- internal_sip_unregister_endpoint_formatter(&endpoint_transport_formatter);
+ ast_sip_unregister_endpoint_formatter(&endpoint_transport_formatter);
ao2_ref(transport_states, -1);
transport_states = NULL;
diff --git a/res/res_pjsip/include/res_pjsip_private.h b/res/res_pjsip/include/res_pjsip_private.h
index 5ce3c6faf..7d434aa95 100644
--- a/res/res_pjsip/include/res_pjsip_private.h
+++ b/res/res_pjsip/include/res_pjsip_private.h
@@ -314,58 +314,10 @@ int sip_cli_print_global(struct ast_sip_cli_context *context);
*/
int sip_cli_print_system(struct ast_sip_cli_context *context);
-/*!
- * \internal
- * \brief Used by res_pjsip.so to register a service without adding a self reference
- */
-int internal_sip_register_service(pjsip_module *module);
-
-/*!
- * \internal
- * \brief Used by res_pjsip.so to unregister a service without removing a self reference
- */
-int internal_sip_unregister_service(pjsip_module *module);
-
-/*!
- * \internal
- * \brief Used by res_pjsip.so to register a supplement without adding a self reference
- */
-void internal_sip_register_supplement(struct ast_sip_supplement *supplement);
-
-/*!
- * \internal
- * \brief Used by res_pjsip.so to unregister a supplement without removing a self reference
- */
-int internal_sip_unregister_supplement(struct ast_sip_supplement *supplement);
-
-/*!
- * \internal
- * \brief Used by res_pjsip.so to register an endpoint formatter without adding a self reference
- */
-void internal_sip_register_endpoint_formatter(struct ast_sip_endpoint_formatter *obj);
-
-/*!
- * \internal
- * \brief Used by res_pjsip.so to unregister a endpoint formatter without removing a self reference
- */
-int internal_sip_unregister_endpoint_formatter(struct ast_sip_endpoint_formatter *obj);
-
struct ast_sip_session_supplement;
/*!
* \internal
- * \brief Used by res_pjsip.so to register a session supplement without adding a self reference
- */
-void internal_sip_session_register_supplement(struct ast_sip_session_supplement *supplement);
-
-/*!
- * \internal
- * \brief Used by res_pjsip.so to unregister a session supplement without removing a self reference
- */
-int internal_sip_session_unregister_supplement(struct ast_sip_session_supplement *supplement);
-
-/*!
- * \internal
* \brief Finds or creates contact_status for a contact
*/
struct ast_sip_contact_status *ast_res_pjsip_find_or_create_contact_status(const struct ast_sip_contact *contact);
@@ -395,4 +347,18 @@ int ast_sip_initialize_scheduler(void);
*/
int ast_sip_destroy_scheduler(void);
+/*!
+ * \internal
+ * \brief Determines if a uri will still be valid after an asterisk restart
+ * \since 13.20.0
+ *
+ * \param uri uri to test
+ * \param endpoint The associated endpoint
+ * \param rdata The rdata to get transport information from
+ *
+ * \retval 1 Yes, 0 No
+ */
+int ast_sip_will_uri_survive_restart(pjsip_sip_uri *uri, struct ast_sip_endpoint *endpoint,
+ pjsip_rx_data *rdata);
+
#endif /* RES_PJSIP_PRIVATE_H_ */
diff --git a/res/res_pjsip/location.c b/res/res_pjsip/location.c
index eb9e58870..84f73c742 100644
--- a/res/res_pjsip/location.c
+++ b/res/res_pjsip/location.c
@@ -1346,7 +1346,7 @@ int ast_sip_initialize_sorcery_location(void)
ast_sorcery_object_field_register(sorcery, "aor", "outbound_proxy", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_aor, outbound_proxy));
ast_sorcery_object_field_register(sorcery, "aor", "support_path", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_aor, support_path));
- internal_sip_register_endpoint_formatter(&endpoint_aor_formatter);
+ ast_sip_register_endpoint_formatter(&endpoint_aor_formatter);
contact_formatter = ao2_alloc(sizeof(struct ast_sip_cli_formatter_entry), NULL);
if (!contact_formatter) {
@@ -1402,7 +1402,7 @@ int ast_sip_destroy_sorcery_location(void)
ast_sip_unregister_cli_formatter(aor_formatter);
ast_manager_unregister("PJSIPShowAors");
- internal_sip_unregister_endpoint_formatter(&endpoint_aor_formatter);
+ ast_sip_unregister_endpoint_formatter(&endpoint_aor_formatter);
return 0;
}
diff --git a/res/res_pjsip/pjsip_distributor.c b/res/res_pjsip/pjsip_distributor.c
index b4828d89f..c239c1a79 100644
--- a/res/res_pjsip/pjsip_distributor.c
+++ b/res/res_pjsip/pjsip_distributor.c
@@ -1243,15 +1243,15 @@ int ast_sip_initialize_distributor(void)
return -1;
}
- if (internal_sip_register_service(&distributor_mod)) {
+ if (ast_sip_register_service(&distributor_mod)) {
ast_sip_destroy_distributor();
return -1;
}
- if (internal_sip_register_service(&endpoint_mod)) {
+ if (ast_sip_register_service(&endpoint_mod)) {
ast_sip_destroy_distributor();
return -1;
}
- if (internal_sip_register_service(&auth_mod)) {
+ if (ast_sip_register_service(&auth_mod)) {
ast_sip_destroy_distributor();
return -1;
}
@@ -1282,9 +1282,9 @@ void ast_sip_destroy_distributor(void)
ast_cli_unregister_multiple(cli_commands, ARRAY_LEN(cli_commands));
ast_sip_unregister_cli_formatter(unid_formatter);
- internal_sip_unregister_service(&auth_mod);
- internal_sip_unregister_service(&endpoint_mod);
- internal_sip_unregister_service(&distributor_mod);
+ ast_sip_unregister_service(&auth_mod);
+ ast_sip_unregister_service(&endpoint_mod);
+ ast_sip_unregister_service(&distributor_mod);
ao2_global_obj_release(artificial_auth);
ao2_cleanup(artificial_endpoint);
diff --git a/res/res_pjsip/pjsip_global_headers.c b/res/res_pjsip/pjsip_global_headers.c
index 4de28b586..52075ae5c 100644
--- a/res/res_pjsip/pjsip_global_headers.c
+++ b/res/res_pjsip/pjsip_global_headers.c
@@ -165,7 +165,7 @@ void ast_sip_initialize_global_headers(void)
AST_RWLIST_HEAD_INIT(&request_headers);
AST_RWLIST_HEAD_INIT(&response_headers);
- internal_sip_register_service(&global_header_mod);
+ ast_sip_register_service(&global_header_mod);
}
static void destroy_headers(struct header_list *headers)
@@ -183,5 +183,5 @@ void ast_sip_destroy_global_headers(void)
destroy_headers(&request_headers);
destroy_headers(&response_headers);
- internal_sip_unregister_service(&global_header_mod);
+ ast_sip_unregister_service(&global_header_mod);
}
diff --git a/res/res_pjsip/pjsip_message_filter.c b/res/res_pjsip/pjsip_message_filter.c
index 427aec740..f948c4449 100644
--- a/res/res_pjsip/pjsip_message_filter.c
+++ b/res/res_pjsip/pjsip_message_filter.c
@@ -517,24 +517,24 @@ static pj_bool_t filter_on_rx_message(pjsip_rx_data *rdata)
void ast_res_pjsip_cleanup_message_filter(void)
{
- internal_sip_unregister_service(&filter_module_tsx);
- internal_sip_unregister_service(&filter_module_transport);
- internal_sip_unregister_supplement(&filter_supplement);
- internal_sip_session_unregister_supplement(&filter_session_supplement);
+ ast_sip_unregister_service(&filter_module_tsx);
+ ast_sip_unregister_service(&filter_module_transport);
+ ast_sip_unregister_supplement(&filter_supplement);
+ ast_sip_session_unregister_supplement(&filter_session_supplement);
}
int ast_res_pjsip_init_message_filter(void)
{
- internal_sip_session_register_supplement(&filter_session_supplement);
- internal_sip_register_supplement(&filter_supplement);
+ ast_sip_session_register_supplement(&filter_session_supplement);
+ ast_sip_register_supplement(&filter_supplement);
- if (internal_sip_register_service(&filter_module_transport)) {
+ if (ast_sip_register_service(&filter_module_transport)) {
ast_log(LOG_ERROR, "Could not register message filter module for incoming and outgoing requests\n");
ast_res_pjsip_cleanup_message_filter();
return -1;
}
- if (internal_sip_register_service(&filter_module_tsx)) {
+ if (ast_sip_register_service(&filter_module_tsx)) {
ast_log(LOG_ERROR, "Could not register message filter module for incoming and outgoing requests\n");
ast_res_pjsip_cleanup_message_filter();
return -1;
diff --git a/res/res_pjsip/pjsip_options.c b/res/res_pjsip/pjsip_options.c
index 3465eae34..4ae1f31d1 100644
--- a/res/res_pjsip/pjsip_options.c
+++ b/res/res_pjsip/pjsip_options.c
@@ -1562,7 +1562,7 @@ int ast_res_pjsip_init_options_handling(int reload)
return -1;
}
- internal_sip_register_endpoint_formatter(&contact_status_formatter);
+ ast_sip_register_endpoint_formatter(&contact_status_formatter);
ast_manager_register_xml("PJSIPQualify", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, ami_sip_qualify);
ast_manager_register_xml("PJSIPShowContacts", EVENT_FLAG_SYSTEM, ami_show_contacts);
ast_cli_register_multiple(cli_options, ARRAY_LEN(cli_options));
@@ -1578,7 +1578,7 @@ void ast_res_pjsip_cleanup_options_handling(void)
ast_cli_unregister_multiple(cli_options, ARRAY_LEN(cli_options));
ast_manager_unregister("PJSIPQualify");
ast_manager_unregister("PJSIPShowContacts");
- internal_sip_unregister_endpoint_formatter(&contact_status_formatter);
+ ast_sip_unregister_endpoint_formatter(&contact_status_formatter);
ast_sorcery_observer_remove(ast_sip_get_sorcery(), "aor", &observer_callbacks_options);
pjsip_endpt_unregister_module(ast_sip_get_pjsip_endpoint(), &options_module);
diff --git a/res/res_pjsip/pjsip_session.c b/res/res_pjsip/pjsip_session.c
index 153561ce7..f3f3a4d87 100644
--- a/res/res_pjsip/pjsip_session.c
+++ b/res/res_pjsip/pjsip_session.c
@@ -32,7 +32,7 @@
AST_RWLIST_HEAD_STATIC(session_supplements, ast_sip_session_supplement);
-void internal_sip_session_register_supplement(struct ast_sip_session_supplement *supplement)
+void ast_sip_session_register_supplement(struct ast_sip_session_supplement *supplement)
{
struct ast_sip_session_supplement *iter;
int inserted = 0;
@@ -56,39 +56,18 @@ void internal_sip_session_register_supplement(struct ast_sip_session_supplement
}
}
-int __ast_sip_session_register_supplement(struct ast_sip_session_supplement *supplement,
- const char *file, int line, const char *func)
-{
- internal_sip_session_register_supplement(supplement);
- __ast_module_ref(AST_MODULE_SELF, file, line, func);
-
- return 0;
-}
-
-int internal_sip_session_unregister_supplement(struct ast_sip_session_supplement *supplement)
+void ast_sip_session_unregister_supplement(struct ast_sip_session_supplement *supplement)
{
struct ast_sip_session_supplement *iter;
- int res = -1;
SCOPED_LOCK(lock, &session_supplements, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&session_supplements, iter, next) {
if (supplement == iter) {
AST_RWLIST_REMOVE_CURRENT(next);
- res = 0;
break;
}
}
AST_RWLIST_TRAVERSE_SAFE_END;
-
- return res;
-}
-
-void __ast_sip_session_unregister_supplement(struct ast_sip_session_supplement *supplement,
- const char *file, int line, const char *func)
-{
- if (!internal_sip_session_unregister_supplement(supplement)) {
- __ast_module_unref(AST_MODULE_SELF, file, line, func);
- }
}
static struct ast_sip_session_supplement *supplement_dup(const struct ast_sip_session_supplement *src)
diff --git a/res/res_pjsip/pjsip_transport_events.c b/res/res_pjsip/pjsip_transport_events.c
index 0f57303ba..c701b8411 100644
--- a/res/res_pjsip/pjsip_transport_events.c
+++ b/res/res_pjsip/pjsip_transport_events.c
@@ -135,7 +135,7 @@ static void transport_state_callback(pjsip_transport *transport,
break;
}
monitored->transport = transport;
- if (AST_VECTOR_INIT(&monitored->monitors, 2)) {
+ if (AST_VECTOR_INIT(&monitored->monitors, 5)) {
ao2_ref(monitored, -1);
break;
}
@@ -166,6 +166,8 @@ static void transport_state_callback(pjsip_transport *transport,
struct transport_monitor_notifier *notifier;
notifier = AST_VECTOR_GET_ADDR(&monitored->monitors, idx);
+ ast_debug(3, "running callback %p(%p) for transport %s\n",
+ notifier->cb, notifier->data, transport->obj_name);
notifier->cb(notifier->data);
}
ao2_ref(monitored, -1);
@@ -195,43 +197,66 @@ static void transport_state_callback(pjsip_transport *transport,
}
}
-static int transport_monitor_unregister_all(void *obj, void *arg, int flags)
+struct callback_data {
+ ast_transport_monitor_shutdown_cb cb;
+ void *data;
+ ast_transport_monitor_data_matcher matches;
+};
+
+static int transport_monitor_unregister_cb(void *obj, void *arg, int flags)
{
struct transport_monitor *monitored = obj;
- ast_transport_monitor_shutdown_cb cb = arg;
+ struct callback_data *cb_data = arg;
int idx;
for (idx = AST_VECTOR_SIZE(&monitored->monitors); idx--;) {
struct transport_monitor_notifier *notifier;
notifier = AST_VECTOR_GET_ADDR(&monitored->monitors, idx);
- if (notifier->cb == cb) {
+ if (notifier->cb == cb_data->cb && (!cb_data->data
+ || cb_data->matches(cb_data->data, notifier->data))) {
ao2_cleanup(notifier->data);
AST_VECTOR_REMOVE_UNORDERED(&monitored->monitors, idx);
- break;
+ ast_debug(3, "Unregistered monitor %p(%p) from transport %s\n",
+ notifier->cb, notifier->data, monitored->transport->obj_name);
}
}
return 0;
}
-void ast_sip_transport_monitor_unregister_all(ast_transport_monitor_shutdown_cb cb)
+static int ptr_matcher(void *a, void *b)
+{
+ return a == b;
+}
+
+void ast_sip_transport_monitor_unregister_all(ast_transport_monitor_shutdown_cb cb,
+ void *data, ast_transport_monitor_data_matcher matches)
{
struct ao2_container *transports;
+ struct callback_data cb_data = {
+ .cb = cb,
+ .data = data,
+ .matches = matches ?: ptr_matcher,
+ };
+
+ ast_assert(cb != NULL);
transports = ao2_global_obj_ref(active_transports);
if (!transports) {
return;
}
- ao2_callback(transports, OBJ_MULTIPLE | OBJ_NODATA, transport_monitor_unregister_all,
- cb);
+ ao2_callback(transports, OBJ_MULTIPLE | OBJ_NODATA, transport_monitor_unregister_cb, &cb_data);
ao2_ref(transports, -1);
}
-void ast_sip_transport_monitor_unregister(pjsip_transport *transport, ast_transport_monitor_shutdown_cb cb)
+void ast_sip_transport_monitor_unregister(pjsip_transport *transport,
+ ast_transport_monitor_shutdown_cb cb, void *data, ast_transport_monitor_data_matcher matches)
{
struct ao2_container *transports;
struct transport_monitor *monitored;
+ ast_assert(transport != NULL && cb != NULL);
+
transports = ao2_global_obj_ref(active_transports);
if (!transports) {
return;
@@ -240,18 +265,13 @@ void ast_sip_transport_monitor_unregister(pjsip_transport *transport, ast_transp
ao2_lock(transports);
monitored = ao2_find(transports, transport->obj_name, OBJ_SEARCH_KEY | OBJ_NOLOCK);
if (monitored) {
- int idx;
+ struct callback_data cb_data = {
+ .cb = cb,
+ .data = data,
+ .matches = matches ?: ptr_matcher,
+ };
- for (idx = AST_VECTOR_SIZE(&monitored->monitors); idx--;) {
- struct transport_monitor_notifier *notifier;
-
- notifier = AST_VECTOR_GET_ADDR(&monitored->monitors, idx);
- if (notifier->cb == cb) {
- ao2_cleanup(notifier->data);
- AST_VECTOR_REMOVE_UNORDERED(&monitored->monitors, idx);
- break;
- }
- }
+ transport_monitor_unregister_cb(monitored, &cb_data, 0);
ao2_ref(monitored, -1);
}
ao2_unlock(transports);
@@ -265,6 +285,8 @@ enum ast_transport_monitor_reg ast_sip_transport_monitor_register(pjsip_transpor
struct transport_monitor *monitored;
enum ast_transport_monitor_reg res = AST_TRANSPORT_MONITOR_REG_NOT_FOUND;
+ ast_assert(transport != NULL && cb != NULL);
+
transports = ao2_global_obj_ref(active_transports);
if (!transports) {
return res;
@@ -273,31 +295,22 @@ enum ast_transport_monitor_reg ast_sip_transport_monitor_register(pjsip_transpor
ao2_lock(transports);
monitored = ao2_find(transports, transport->obj_name, OBJ_SEARCH_KEY | OBJ_NOLOCK);
if (monitored) {
- int idx;
struct transport_monitor_notifier new_monitor;
- /* Check if the callback monitor already exists */
- for (idx = AST_VECTOR_SIZE(&monitored->monitors); idx--;) {
- struct transport_monitor_notifier *notifier;
-
- notifier = AST_VECTOR_GET_ADDR(&monitored->monitors, idx);
- if (notifier->cb == cb) {
- /* The monitor is already in the vector replace with new ao2_data. */
- ao2_replace(notifier->data, ao2_data);
- res = AST_TRANSPORT_MONITOR_REG_REPLACED;
- goto register_done;
- }
- }
-
/* Add new monitor to vector */
new_monitor.cb = cb;
new_monitor.data = ao2_bump(ao2_data);
if (AST_VECTOR_APPEND(&monitored->monitors, new_monitor)) {
ao2_cleanup(ao2_data);
res = AST_TRANSPORT_MONITOR_REG_FAILED;
+ ast_debug(3, "Register monitor %p(%p) to transport %s FAILED\n",
+ cb, ao2_data, transport->obj_name);
+ } else {
+ res = AST_TRANSPORT_MONITOR_REG_SUCCESS;
+ ast_debug(3, "Registered monitor %p(%p) to transport %s\n",
+ cb, ao2_data, transport->obj_name);
}
-register_done:
ao2_ref(monitored, -1);
}
ao2_unlock(transports);
diff --git a/res/res_pjsip_acl.c b/res/res_pjsip_acl.c
index 926986422..8caf70344 100644
--- a/res/res_pjsip_acl.c
+++ b/res/res_pjsip_acl.c
@@ -282,8 +282,6 @@ static void *acl_alloc(const char *name)
static int load_module(void)
{
- CHECK_PJSIP_MODULE_LOADED();
-
ast_sorcery_apply_config(ast_sip_get_sorcery(), SIP_SORCERY_ACL_TYPE);
ast_sorcery_apply_default(ast_sip_get_sorcery(), SIP_SORCERY_ACL_TYPE,
"config", "pjsip.conf,criteria=type=acl");
diff --git a/res/res_pjsip_authenticator_digest.c b/res/res_pjsip_authenticator_digest.c
index b6f2b74ff..518ef73bb 100644
--- a/res/res_pjsip_authenticator_digest.c
+++ b/res/res_pjsip_authenticator_digest.c
@@ -524,8 +524,6 @@ static int reload_module(void)
static int load_module(void)
{
- CHECK_PJSIP_MODULE_LOADED();
-
if (build_entity_id()) {
return AST_MODULE_LOAD_DECLINE;
}
diff --git a/res/res_pjsip_caller_id.c b/res/res_pjsip_caller_id.c
index 16731479e..f15a66c05 100644
--- a/res/res_pjsip_caller_id.c
+++ b/res/res_pjsip_caller_id.c
@@ -746,8 +746,6 @@ static struct ast_sip_session_supplement caller_id_supplement = {
static int load_module(void)
{
- CHECK_PJSIP_SESSION_MODULE_LOADED();
-
ast_sip_session_register_supplement(&caller_id_supplement);
return AST_MODULE_LOAD_SUCCESS;
}
diff --git a/res/res_pjsip_dialog_info_body_generator.c b/res/res_pjsip_dialog_info_body_generator.c
index 866ea9df8..a13995fac 100644
--- a/res/res_pjsip_dialog_info_body_generator.c
+++ b/res/res_pjsip_dialog_info_body_generator.c
@@ -198,8 +198,6 @@ static struct ast_sip_pubsub_body_generator dialog_info_body_generator = {
static int load_module(void)
{
- CHECK_PJSIP_PUBSUB_MODULE_LOADED();
-
if (ast_sip_pubsub_register_body_generator(&dialog_info_body_generator)) {
return AST_MODULE_LOAD_DECLINE;
}
diff --git a/res/res_pjsip_diversion.c b/res/res_pjsip_diversion.c
index 84c42dca8..e82140b72 100644
--- a/res/res_pjsip_diversion.c
+++ b/res/res_pjsip_diversion.c
@@ -411,8 +411,6 @@ static struct ast_sip_session_supplement diversion_supplement = {
static int load_module(void)
{
- CHECK_PJSIP_SESSION_MODULE_LOADED();
-
ast_sip_session_register_supplement(&diversion_supplement);
return AST_MODULE_LOAD_SUCCESS;
}
@@ -428,5 +426,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PJSIP Add Diversion H
.load = load_module,
.unload = unload_module,
.load_pri = AST_MODPRI_APP_DEPEND,
- .requires = "res_pjsip",
+ .requires = "res_pjsip,res_pjsip_session",
);
diff --git a/res/res_pjsip_dlg_options.c b/res/res_pjsip_dlg_options.c
index 565ad2afc..93e3f228e 100644
--- a/res/res_pjsip_dlg_options.c
+++ b/res/res_pjsip_dlg_options.c
@@ -83,11 +83,8 @@ static struct ast_sip_session_supplement dlg_options_supplement = {
static int load_module(void)
{
- CHECK_PJSIP_MODULE_LOADED();
+ ast_sip_session_register_supplement(&dlg_options_supplement);
- if (ast_sip_session_register_supplement(&dlg_options_supplement)) {
- return AST_MODULE_LOAD_DECLINE;
- }
return AST_MODULE_LOAD_SUCCESS;
}
diff --git a/res/res_pjsip_dtmf_info.c b/res/res_pjsip_dtmf_info.c
index 68df61785..983498def 100644
--- a/res/res_pjsip_dtmf_info.c
+++ b/res/res_pjsip_dtmf_info.c
@@ -160,8 +160,6 @@ static struct ast_sip_session_supplement dtmf_info_supplement = {
static int load_module(void)
{
- CHECK_PJSIP_SESSION_MODULE_LOADED();
-
ast_sip_session_register_supplement(&dtmf_info_supplement);
return AST_MODULE_LOAD_SUCCESS;
}
@@ -177,5 +175,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PJSIP DTMF INFO Suppo
.load = load_module,
.unload = unload_module,
.load_pri = AST_MODPRI_APP_DEPEND,
- .requires = "res_pjsip",
+ .requires = "res_pjsip,res_pjsip_session",
);
diff --git a/res/res_pjsip_empty_info.c b/res/res_pjsip_empty_info.c
index c67835ce0..74e5729a5 100644
--- a/res/res_pjsip_empty_info.c
+++ b/res/res_pjsip_empty_info.c
@@ -66,8 +66,6 @@ static struct ast_sip_session_supplement empty_info_supplement = {
static int load_module(void)
{
- CHECK_PJSIP_SESSION_MODULE_LOADED();
-
ast_sip_session_register_supplement(&empty_info_supplement);
return AST_MODULE_LOAD_SUCCESS;
}
@@ -83,5 +81,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PJSIP Empty INFO Supp
.load = load_module,
.unload = unload_module,
.load_pri = AST_MODPRI_APP_DEPEND,
- .requires = "res_pjsip",
+ .requires = "res_pjsip,res_pjsip_session",
);
diff --git a/res/res_pjsip_endpoint_identifier_anonymous.c b/res/res_pjsip_endpoint_identifier_anonymous.c
index 16662ebd5..918aec553 100644
--- a/res/res_pjsip_endpoint_identifier_anonymous.c
+++ b/res/res_pjsip_endpoint_identifier_anonymous.c
@@ -116,8 +116,6 @@ static struct ast_sip_endpoint_identifier anonymous_identifier = {
static int load_module(void)
{
- CHECK_PJSIP_MODULE_LOADED();
-
ast_sip_register_endpoint_identifier_with_name(&anonymous_identifier, "anonymous");
return AST_MODULE_LOAD_SUCCESS;
}
diff --git a/res/res_pjsip_endpoint_identifier_ip.c b/res/res_pjsip_endpoint_identifier_ip.c
index ee47e4d4e..555d65331 100644
--- a/res/res_pjsip_endpoint_identifier_ip.c
+++ b/res/res_pjsip_endpoint_identifier_ip.c
@@ -717,8 +717,6 @@ static struct ast_sip_cli_formatter_entry *cli_formatter;
static int load_module(void)
{
- CHECK_PJSIP_MODULE_LOADED();
-
ast_sorcery_apply_config(ast_sip_get_sorcery(), "res_pjsip_endpoint_identifier_ip");
ast_sorcery_apply_default(ast_sip_get_sorcery(), "identify", "config", "pjsip.conf,criteria=type=identify");
diff --git a/res/res_pjsip_endpoint_identifier_user.c b/res/res_pjsip_endpoint_identifier_user.c
index 1b0c7d99a..e18d2fab3 100644
--- a/res/res_pjsip_endpoint_identifier_user.c
+++ b/res/res_pjsip_endpoint_identifier_user.c
@@ -195,8 +195,6 @@ static struct ast_sip_endpoint_identifier auth_username_identifier = {
static int load_module(void)
{
- CHECK_PJSIP_MODULE_LOADED();
-
ast_sip_register_endpoint_identifier_with_name(&username_identifier, "username");
ast_sip_register_endpoint_identifier_with_name(&auth_username_identifier, "auth_username");
return AST_MODULE_LOAD_SUCCESS;
diff --git a/res/res_pjsip_exten_state.c b/res/res_pjsip_exten_state.c
index e70eba7cd..47ec8b461 100644
--- a/res/res_pjsip_exten_state.c
+++ b/res/res_pjsip_exten_state.c
@@ -959,13 +959,6 @@ static int unload_module(void)
static int load_module(void)
{
- CHECK_PJSIP_PUBSUB_MODULE_LOADED();
-
- if (!ast_module_check("res_pjsip_outbound_publish.so")) {
- ast_log(LOG_WARNING, "This module requires the 'res_pjsip_outbound_publish.so' module to be loaded\n");
- return AST_MODULE_LOAD_DECLINE;
- }
-
publishers = ao2_container_alloc(PUBLISHER_BUCKETS, exten_state_publisher_hash,
exten_state_publisher_cmp);
if (!publishers) {
diff --git a/res/res_pjsip_header_funcs.c b/res/res_pjsip_header_funcs.c
index 06fba0635..79302632d 100644
--- a/res/res_pjsip_header_funcs.c
+++ b/res/res_pjsip_header_funcs.c
@@ -609,8 +609,6 @@ static struct ast_sip_session_supplement header_funcs_supplement = {
static int load_module(void)
{
- CHECK_PJSIP_SESSION_MODULE_LOADED();
-
ast_sip_session_register_supplement(&header_funcs_supplement);
ast_custom_function_register(&pjsip_header_function);
diff --git a/res/res_pjsip_history.c b/res/res_pjsip_history.c
index 40d26d59d..fa9e27f00 100644
--- a/res/res_pjsip_history.c
+++ b/res/res_pjsip_history.c
@@ -1364,8 +1364,6 @@ static struct ast_cli_entry cli_pjsip[] = {
static int load_module(void)
{
- CHECK_PJSIP_MODULE_LOADED();
-
log_level = ast_logger_register_level("PJSIP_HISTORY");
if (log_level < 0) {
ast_log(LOG_WARNING, "Unable to register history log level\n");
diff --git a/res/res_pjsip_logger.c b/res/res_pjsip_logger.c
index 460b6a34f..49ad6faec 100644
--- a/res/res_pjsip_logger.c
+++ b/res/res_pjsip_logger.c
@@ -231,8 +231,6 @@ static const struct ast_sorcery_observer global_observer = {
static int load_module(void)
{
- CHECK_PJSIP_MODULE_LOADED();
-
if (ast_sorcery_observer_add(ast_sip_get_sorcery(), "global", &global_observer)) {
ast_log(LOG_WARNING, "Unable to add global observer\n");
return AST_MODULE_LOAD_DECLINE;
diff --git a/res/res_pjsip_messaging.c b/res/res_pjsip_messaging.c
index 3739bcf93..cbaed83fb 100644
--- a/res/res_pjsip_messaging.c
+++ b/res/res_pjsip_messaging.c
@@ -805,8 +805,6 @@ static pjsip_module messaging_module = {
static int load_module(void)
{
- CHECK_PJSIP_SESSION_MODULE_LOADED();
-
if (ast_sip_register_service(&messaging_module) != PJ_SUCCESS) {
return AST_MODULE_LOAD_DECLINE;
}
@@ -849,5 +847,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PJSIP Messaging Suppo
.load = load_module,
.unload = unload_module,
.load_pri = AST_MODPRI_APP_DEPEND,
- .requires = "res_pjsip",
+ .requires = "res_pjsip,res_pjsip_session",
);
diff --git a/res/res_pjsip_mwi.c b/res/res_pjsip_mwi.c
index 92dc7dc65..4cd892c05 100644
--- a/res/res_pjsip_mwi.c
+++ b/res/res_pjsip_mwi.c
@@ -650,11 +650,11 @@ static void send_mwi_notify(struct mwi_subscription *sub)
.body_type = AST_SIP_MESSAGE_ACCUMULATOR,
.body_data = &counter,
};
- const char *resource = ast_sip_subscription_get_resource_name(sub->sip_sub);
ao2_callback(sub->stasis_subs, OBJ_NODATA, get_message_count, &counter);
if (sub->is_solicited) {
+ const char *resource = ast_sip_subscription_get_resource_name(sub->sip_sub);
struct ast_sip_endpoint *endpoint = ast_sip_subscription_get_endpoint(sub->sip_sub);
struct ast_sip_aor *aor = find_aor_for_resource(endpoint, resource);
pjsip_dialog *dlg = ast_sip_subscription_get_dialog(sub->sip_sub);
@@ -1339,8 +1339,6 @@ static int reload(void)
static int load_module(void)
{
- CHECK_PJSIP_MODULE_LOADED();
-
if (ast_sip_register_subscription_handler(&mwi_handler)) {
return AST_MODULE_LOAD_DECLINE;
}
diff --git a/res/res_pjsip_mwi_body_generator.c b/res/res_pjsip_mwi_body_generator.c
index 65ac60067..29b2ed027 100644
--- a/res/res_pjsip_mwi_body_generator.c
+++ b/res/res_pjsip_mwi_body_generator.c
@@ -97,8 +97,6 @@ static struct ast_sip_pubsub_body_generator mwi_generator = {
static int load_module(void)
{
- CHECK_PJSIP_PUBSUB_MODULE_LOADED();
-
if (ast_sip_pubsub_register_body_generator(&mwi_generator)) {
return AST_MODULE_LOAD_DECLINE;
}
diff --git a/res/res_pjsip_nat.c b/res/res_pjsip_nat.c
index 4231a1ec3..1d42805d8 100644
--- a/res/res_pjsip_nat.c
+++ b/res/res_pjsip_nat.c
@@ -357,18 +357,12 @@ static int unload_module(void)
static int load_module(void)
{
- CHECK_PJSIP_SESSION_MODULE_LOADED();
-
if (ast_sip_register_service(&nat_module)) {
ast_log(LOG_ERROR, "Could not register NAT module for incoming and outgoing requests\n");
return AST_MODULE_LOAD_DECLINE;
}
- if (ast_sip_session_register_supplement(&nat_supplement)) {
- ast_log(LOG_ERROR, "Could not register NAT session supplement for incoming and outgoing INVITE requests\n");
- unload_module();
- return AST_MODULE_LOAD_DECLINE;
- }
+ ast_sip_session_register_supplement(&nat_supplement);
return AST_MODULE_LOAD_SUCCESS;
}
@@ -378,5 +372,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PJSIP NAT Support",
.load = load_module,
.unload = unload_module,
.load_pri = AST_MODPRI_APP_DEPEND,
- .requires = "res_pjsip",
+ .requires = "res_pjsip,res_pjsip_session",
);
diff --git a/res/res_pjsip_notify.c b/res/res_pjsip_notify.c
index 9767c56b5..253cf9ac8 100644
--- a/res/res_pjsip_notify.c
+++ b/res/res_pjsip_notify.c
@@ -987,8 +987,6 @@ static int manager_notify(struct mansession *s, const struct message *m)
static int load_module(void)
{
- CHECK_PJSIP_MODULE_LOADED();
-
if (aco_info_init(&notify_cfg)) {
return AST_MODULE_LOAD_DECLINE;
}
diff --git a/res/res_pjsip_one_touch_record_info.c b/res/res_pjsip_one_touch_record_info.c
index ef59fca13..50f2a3832 100644
--- a/res/res_pjsip_one_touch_record_info.c
+++ b/res/res_pjsip_one_touch_record_info.c
@@ -107,12 +107,7 @@ static struct ast_sip_session_supplement info_supplement = {
static int load_module(void)
{
- CHECK_PJSIP_SESSION_MODULE_LOADED();
-
- if (ast_sip_session_register_supplement(&info_supplement)) {
- ast_log(LOG_ERROR, "Unable to register One Touch Recording supplement\n");
- return AST_MODULE_LOAD_DECLINE;
- }
+ ast_sip_session_register_supplement(&info_supplement);
return AST_MODULE_LOAD_SUCCESS;
}
@@ -128,5 +123,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PJSIP INFO One Touch
.load = load_module,
.unload = unload_module,
.load_pri = AST_MODPRI_APP_DEPEND,
- .requires = "res_pjsip",
+ .requires = "res_pjsip,res_pjsip_session",
);
diff --git a/res/res_pjsip_outbound_authenticator_digest.c b/res/res_pjsip_outbound_authenticator_digest.c
index 54bba08de..063b4d3eb 100644
--- a/res/res_pjsip_outbound_authenticator_digest.c
+++ b/res/res_pjsip_outbound_authenticator_digest.c
@@ -205,8 +205,6 @@ static struct ast_sip_outbound_authenticator digest_authenticator = {
static int load_module(void)
{
- CHECK_PJSIP_MODULE_LOADED();
-
if (ast_sip_register_outbound_authenticator(&digest_authenticator)) {
return AST_MODULE_LOAD_DECLINE;
}
diff --git a/res/res_pjsip_outbound_publish.c b/res/res_pjsip_outbound_publish.c
index b4e3320f4..75e74a26f 100644
--- a/res/res_pjsip_outbound_publish.c
+++ b/res/res_pjsip_outbound_publish.c
@@ -345,7 +345,6 @@ AST_RWLIST_HEAD_STATIC(publisher_handlers, ast_sip_event_publisher_handler);
static void sub_add_handler(struct ast_sip_event_publisher_handler *handler)
{
AST_RWLIST_INSERT_TAIL(&publisher_handlers, handler, next);
- ast_module_ref(ast_module_info->self);
}
static struct ast_sip_event_publisher_handler *find_publisher_handler_for_event_name(const char *event_name)
@@ -643,7 +642,6 @@ void ast_sip_unregister_event_publisher_handler(struct ast_sip_event_publisher_h
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&publisher_handlers, iter, next) {
if (handler == iter) {
AST_RWLIST_REMOVE_CURRENT(next);
- ast_module_unref(ast_module_info->self);
break;
}
}
@@ -1643,8 +1641,6 @@ static int unload_module(void)
static int load_module(void)
{
- CHECK_PJSIP_MODULE_LOADED();
-
/* As of pjproject 2.4.5, PJSIP_MAX_URL_SIZE isn't exposed yet but we try anyway. */
ast_pjproject_get_buildopt("PJSIP_MAX_URL_SIZE", "%d", &pjsip_max_url_size);
diff --git a/res/res_pjsip_outbound_registration.c b/res/res_pjsip_outbound_registration.c
index 79bea482b..d0f754604 100644
--- a/res/res_pjsip_outbound_registration.c
+++ b/res/res_pjsip_outbound_registration.c
@@ -850,6 +850,14 @@ static void registration_transport_shutdown_cb(void *obj)
}
}
+static int monitor_matcher(void *a, void *b)
+{
+ char *ma = a;
+ char *mb = b;
+
+ return strcmp(ma, mb) == 0;
+}
+
static void registration_transport_monitor_setup(pjsip_transport *transport, const char *registration_name)
{
char *monitor;
@@ -950,7 +958,8 @@ static int handle_registration_response(void *data)
ast_debug(1, "Outbound unregistration to '%s' with client '%s' successful\n", server_uri, client_uri);
update_client_state_status(response->client_state, SIP_REGISTRATION_UNREGISTERED);
ast_sip_transport_monitor_unregister(response->rdata->tp_info.transport,
- registration_transport_shutdown_cb);
+ registration_transport_shutdown_cb, response->client_state->registration_name,
+ monitor_matcher);
}
} else if (response->client_state->destroy) {
/* We need to deal with the pending destruction instead. */
@@ -2149,7 +2158,7 @@ static int unload_module(void)
ao2_global_obj_release(current_states);
- ast_sip_transport_monitor_unregister_all(registration_transport_shutdown_cb);
+ ast_sip_transport_monitor_unregister_all(registration_transport_shutdown_cb, NULL, NULL);
/* Wait for registration serializers to get destroyed. */
ast_debug(2, "Waiting for registration transactions to complete for unload.\n");
@@ -2177,8 +2186,6 @@ static int load_module(void)
{
struct ao2_container *new_states;
- CHECK_PJSIP_MODULE_LOADED();
-
shutdown_group = ast_serializer_shutdown_group_alloc();
if (!shutdown_group) {
return AST_MODULE_LOAD_DECLINE;
@@ -2290,4 +2297,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PJSIP Outbound Regist
.unload = unload_module,
.load_pri = AST_MODPRI_APP_DEPEND,
.requires = "res_pjsip",
+ .optional_modules = "res_statsd",
);
diff --git a/res/res_pjsip_path.c b/res/res_pjsip_path.c
index b245f159d..3c545f9d2 100644
--- a/res/res_pjsip_path.c
+++ b/res/res_pjsip_path.c
@@ -238,16 +238,8 @@ static struct ast_sip_session_supplement path_session_supplement = {
static int load_module(void)
{
- CHECK_PJSIP_SESSION_MODULE_LOADED();
-
- if (ast_sip_register_supplement(&path_supplement)) {
- return AST_MODULE_LOAD_DECLINE;
- }
-
- if (ast_sip_session_register_supplement(&path_session_supplement)) {
- ast_sip_unregister_supplement(&path_supplement);
- return AST_MODULE_LOAD_DECLINE;
- }
+ ast_sip_register_supplement(&path_supplement);
+ ast_sip_session_register_supplement(&path_session_supplement);
return AST_MODULE_LOAD_SUCCESS;
}
@@ -264,5 +256,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PJSIP Path Header Sup
.load = load_module,
.unload = unload_module,
.load_pri = AST_MODPRI_APP_DEPEND,
- .requires = "res_pjsip",
+ .requires = "res_pjsip,res_pjsip_session",
);
diff --git a/res/res_pjsip_phoneprov_provider.c b/res/res_pjsip_phoneprov_provider.c
index 11031c3c1..acb1e68b5 100644
--- a/res/res_pjsip_phoneprov_provider.c
+++ b/res/res_pjsip_phoneprov_provider.c
@@ -367,8 +367,6 @@ static int load_users(void)
static int load_module(void)
{
- CHECK_PJSIP_MODULE_LOADED();
-
sorcery = ast_sip_get_sorcery();
ast_sorcery_apply_config(sorcery, "res_pjsip_phoneprov_provider");
diff --git a/res/res_pjsip_pidf_body_generator.c b/res/res_pjsip_pidf_body_generator.c
index 6426dfa9d..8bc062e08 100644
--- a/res/res_pjsip_pidf_body_generator.c
+++ b/res/res_pjsip_pidf_body_generator.c
@@ -116,8 +116,6 @@ static struct ast_sip_pubsub_body_generator pidf_body_generator = {
static int load_module(void)
{
- CHECK_PJSIP_PUBSUB_MODULE_LOADED();
-
if (ast_sip_pubsub_register_body_generator(&pidf_body_generator)) {
return AST_MODULE_LOAD_DECLINE;
}
diff --git a/res/res_pjsip_pidf_digium_body_supplement.c b/res/res_pjsip_pidf_digium_body_supplement.c
index f855e2153..832f42302 100644
--- a/res/res_pjsip_pidf_digium_body_supplement.c
+++ b/res/res_pjsip_pidf_digium_body_supplement.c
@@ -95,8 +95,6 @@ static struct ast_sip_pubsub_body_supplement pidf_supplement = {
static int load_module(void)
{
- CHECK_PJSIP_PUBSUB_MODULE_LOADED();
-
if (ast_sip_pubsub_register_body_supplement(&pidf_supplement)) {
return AST_MODULE_LOAD_DECLINE;
}
diff --git a/res/res_pjsip_pidf_eyebeam_body_supplement.c b/res/res_pjsip_pidf_eyebeam_body_supplement.c
index 6629aa3c1..15446bc52 100644
--- a/res/res_pjsip_pidf_eyebeam_body_supplement.c
+++ b/res/res_pjsip_pidf_eyebeam_body_supplement.c
@@ -92,8 +92,6 @@ static struct ast_sip_pubsub_body_supplement pidf_supplement = {
static int load_module(void)
{
- CHECK_PJSIP_PUBSUB_MODULE_LOADED();
-
if (ast_sip_pubsub_register_body_supplement(&pidf_supplement)) {
return AST_MODULE_LOAD_DECLINE;
}
diff --git a/res/res_pjsip_publish_asterisk.c b/res/res_pjsip_publish_asterisk.c
index 13d7fd43b..220ba0bc5 100644
--- a/res/res_pjsip_publish_asterisk.c
+++ b/res/res_pjsip_publish_asterisk.c
@@ -855,8 +855,6 @@ static int regex_filter_handler(const struct aco_option *opt, struct ast_variabl
static int load_module(void)
{
- CHECK_PJSIP_PUBSUB_MODULE_LOADED();
-
if (ast_eid_is_empty(&ast_eid_default)) {
ast_log(LOG_ERROR, "Entity ID is not set.\n");
return AST_MODULE_LOAD_DECLINE;
diff --git a/res/res_pjsip_pubsub.c b/res/res_pjsip_pubsub.c
index af696b849..c78f20c2b 100644
--- a/res/res_pjsip_pubsub.c
+++ b/res/res_pjsip_pubsub.c
@@ -127,6 +127,11 @@
<configOption name="contact_uri">
<synopsis>The Contact URI of the dialog for the subscription</synopsis>
</configOption>
+ <configOption name="prune_on_boot">
+ <synopsis>If set, indicates that the contact used a reliable transport
+ and therefore the subscription must be deleted after an asterisk restart.
+ </synopsis>
+ </configOption>
</configObject>
<configObject name="resource_list">
<synopsis>Resource list configuration parameters.</synopsis>
@@ -382,6 +387,8 @@ struct subscription_persistence {
struct timeval expires;
/*! Contact URI */
char contact_uri[PJSIP_MAX_URL_SIZE];
+ /*! Prune subscription on restart */
+ int prune_on_boot;
};
/*!
@@ -446,6 +453,10 @@ struct sip_subscription_tree {
* capable of restarting the timer.
*/
struct ast_sip_sched_task *expiration_task;
+ /*! The transport the subscription was received on.
+ * Only used for reliable transports.
+ */
+ pjsip_transport *transport;
};
/*!
@@ -549,6 +560,17 @@ static void *publication_resource_alloc(const char *name)
return ast_sorcery_generic_alloc(sizeof(struct ast_sip_publication_resource), publication_resource_destroy);
}
+static void sub_tree_transport_cb(void *data) {
+ struct sip_subscription_tree *sub_tree = data;
+
+ ast_debug(3, "Transport destroyed. Removing subscription '%s->%s' prune on restart: %d\n",
+ sub_tree->persistence->endpoint, sub_tree->root->resource,
+ sub_tree->persistence->prune_on_boot);
+
+ sub_tree->state = SIP_SUB_TREE_TERMINATE_IN_PROGRESS;
+ pjsip_evsub_terminate(sub_tree->evsub, PJ_TRUE);
+}
+
/*! \brief Destructor for subscription persistence */
static void subscription_persistence_destroy(void *obj)
{
@@ -599,8 +621,9 @@ static void subscription_persistence_update(struct sip_subscription_tree *sub_tr
return;
}
- ast_debug(3, "Updating persistence for '%s->%s'\n", sub_tree->persistence->endpoint,
- sub_tree->root->resource);
+ ast_debug(3, "Updating persistence for '%s->%s' prune on restart: %s\n",
+ sub_tree->persistence->endpoint, sub_tree->root->resource,
+ sub_tree->persistence->prune_on_boot ? "yes" : "no");
dlg = sub_tree->dlg;
sub_tree->persistence->cseq = dlg->local.cseq;
@@ -614,6 +637,28 @@ static void subscription_persistence_update(struct sip_subscription_tree *sub_tr
sub_tree->persistence->expires = ast_tvadd(ast_tvnow(), ast_samp2tv(expires, 1));
if (contact_hdr) {
+ if (contact_hdr) {
+ if (type == SUBSCRIPTION_PERSISTENCE_CREATED) {
+ sub_tree->persistence->prune_on_boot =
+ !ast_sip_will_uri_survive_restart(
+ (pjsip_sip_uri *)pjsip_uri_get_uri(contact_hdr->uri),
+ sub_tree->endpoint, rdata);
+
+ if (sub_tree->persistence->prune_on_boot) {
+ ast_debug(3, "adding transport monitor on %s for '%s->%s' prune on restart: %d\n",
+ rdata->tp_info.transport->obj_name,
+ sub_tree->persistence->endpoint, sub_tree->root->resource,
+ sub_tree->persistence->prune_on_boot);
+ sub_tree->transport = rdata->tp_info.transport;
+ ast_sip_transport_monitor_register(rdata->tp_info.transport,
+ sub_tree_transport_cb, sub_tree);
+ /*
+ * FYI: ast_sip_transport_monitor_register holds a reference to the sub_tree
+ */
+ }
+ }
+ }
+
pjsip_uri_print(PJSIP_URI_IN_CONTACT_HDR, contact_hdr->uri,
sub_tree->persistence->contact_uri, sizeof(sub_tree->persistence->contact_uri));
} else {
@@ -656,6 +701,15 @@ static void subscription_persistence_remove(struct sip_subscription_tree *sub_tr
return;
}
+ if (sub_tree->persistence->prune_on_boot && sub_tree->transport) {
+ ast_debug(3, "Unregistering transport monitor on %s '%s->%s'\n",
+ sub_tree->transport->obj_name,
+ sub_tree->endpoint ? ast_sorcery_object_get_id(sub_tree->endpoint) : "Unknown",
+ sub_tree->root ? sub_tree->root->resource : "Unknown");
+ ast_sip_transport_monitor_unregister(sub_tree->transport,
+ sub_tree_transport_cb, sub_tree, NULL);
+ }
+
ast_sorcery_delete(ast_sip_get_sorcery(), sub_tree->persistence);
ao2_ref(sub_tree->persistence, -1);
sub_tree->persistence = NULL;
@@ -1564,6 +1618,14 @@ static int subscription_persistence_recreate(void *obj, void *arg, int flags)
pjsip_rx_data rdata;
struct persistence_recreate_data recreate_data;
+ /* If this subscription used a reliable transport it can't be reestablished so remove it */
+ if (persistence->prune_on_boot) {
+ ast_debug(3, "Deleting subscription marked as 'prune' from persistent store '%s' %s\n",
+ persistence->endpoint, persistence->tag);
+ ast_sorcery_delete(ast_sip_get_sorcery(), persistence);
+ return 0;
+ }
+
/* If this subscription has already expired remove it */
if (ast_tvdiff_ms(persistence->expires, ast_tvnow()) <= 0) {
ast_debug(3, "Expired subscription retrived from persistent store '%s' %s\n",
@@ -2583,8 +2645,6 @@ int ast_sip_register_publish_handler(struct ast_sip_publish_handler *handler)
publish_add_handler(handler);
- ast_module_ref(ast_module_info->self);
-
return 0;
}
@@ -2597,7 +2657,6 @@ void ast_sip_unregister_publish_handler(struct ast_sip_publish_handler *handler)
if (handler == iter) {
AST_RWLIST_REMOVE_CURRENT(next);
ao2_cleanup(handler->publications);
- ast_module_unref(ast_module_info->self);
break;
}
}
@@ -2611,7 +2670,6 @@ static void sub_add_handler(struct ast_sip_subscription_handler *handler)
{
AST_RWLIST_WRLOCK(&subscription_handlers);
AST_RWLIST_INSERT_TAIL(&subscription_handlers, handler, next);
- ast_module_ref(ast_module_info->self);
AST_RWLIST_UNLOCK(&subscription_handlers);
}
@@ -2670,7 +2728,6 @@ void ast_sip_unregister_subscription_handler(struct ast_sip_subscription_handler
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&subscription_handlers, iter, next) {
if (handler == iter) {
AST_RWLIST_REMOVE_CURRENT(next);
- ast_module_unref(ast_module_info->self);
break;
}
}
@@ -5378,8 +5435,6 @@ static int load_module(void)
static const pj_str_t str_PUBLISH = { "PUBLISH", 7 };
struct ast_sorcery *sorcery;
- CHECK_PJSIP_MODULE_LOADED();
-
sorcery = ast_sip_get_sorcery();
if (!(sched = ast_sched_context_create())) {
@@ -5423,6 +5478,8 @@ static int load_module(void)
persistence_expires_str2struct, persistence_expires_struct2str, NULL, 0, 0);
ast_sorcery_object_field_register(sorcery, "subscription_persistence", "contact_uri", "", OPT_CHAR_ARRAY_T, 0,
CHARFLDSET(struct subscription_persistence, contact_uri));
+ ast_sorcery_object_field_register(sorcery, "subscription_persistence", "prune_on_boot", "0", OPT_UINT_T, 0,
+ FLDSET(struct subscription_persistence, prune_on_boot));
if (apply_list_configuration(sorcery)) {
ast_sched_context_destroy(sched);
@@ -5499,6 +5556,8 @@ static int unload_module(void)
AST_TEST_UNREGISTER(loop);
AST_TEST_UNREGISTER(bad_event);
+ ast_sip_transport_monitor_unregister_all(sub_tree_transport_cb, NULL, NULL);
+
ast_cli_unregister_multiple(cli_commands, ARRAY_LEN(cli_commands));
ast_manager_unregister(AMI_SHOW_SUBSCRIPTIONS_OUTBOUND);
diff --git a/res/res_pjsip_refer.c b/res/res_pjsip_refer.c
index 3100993de..5e0141b09 100644
--- a/res/res_pjsip_refer.c
+++ b/res/res_pjsip_refer.c
@@ -1202,8 +1202,6 @@ static int load_module(void)
{
const pj_str_t str_norefersub = { "norefersub", 10 };
- CHECK_PJSIP_SESSION_MODULE_LOADED();
-
pjsip_replaces_init_module(ast_sip_get_pjsip_endpoint());
pjsip_xfer_init_module(ast_sip_get_pjsip_endpoint());
pjsip_endpt_add_capability(ast_sip_get_pjsip_endpoint(), NULL, PJSIP_H_SUPPORTED, NULL, 1, &str_norefersub);
diff --git a/res/res_pjsip_registrar.c b/res/res_pjsip_registrar.c
index 7277a5f4f..bdee91fb3 100644
--- a/res/res_pjsip_registrar.c
+++ b/res/res_pjsip_registrar.c
@@ -25,6 +25,7 @@
#include "asterisk.h"
+#include <signal.h>
#include <pjsip.h>
#include <pjsip_ua.h>
@@ -327,6 +328,15 @@ struct contact_transport_monitor {
char aor_name[0];
};
+static int contact_transport_monitor_matcher(void *a, void *b)
+{
+ struct contact_transport_monitor *ma = a;
+ struct contact_transport_monitor *mb = b;
+
+ return strcmp(ma->aor_name, mb->aor_name) == 0
+ && strcmp(ma->contact_name, mb->contact_name) == 0;
+}
+
static void register_contact_transport_shutdown_cb(void *data)
{
struct contact_transport_monitor *monitor = data;
@@ -578,8 +588,7 @@ static void register_aor_core(pjsip_rx_data *rdata,
contact = ao2_callback(contacts, OBJ_UNLINK, registrar_find_contact, &details);
if (!contact) {
- int prune_on_boot = 0;
- pj_str_t host_name;
+ int prune_on_boot;
/* If they are actually trying to delete a contact that does not exist... be forgiving */
if (!expiration) {
@@ -588,35 +597,7 @@ static void register_aor_core(pjsip_rx_data *rdata,
continue;
}
- /* Determine if the contact cannot survive a restart/boot. */
- if (details.uri->port == rdata->pkt_info.src_port
- && !pj_strcmp(&details.uri->host,
- pj_cstr(&host_name, rdata->pkt_info.src_name))
- /* We have already checked if the URI scheme is sip: or sips: */
- && PJSIP_TRANSPORT_IS_RELIABLE(rdata->tp_info.transport)) {
- pj_str_t type_name;
-
- /* Determine the transport parameter value */
- if (!strcasecmp("WSS", rdata->tp_info.transport->type_name)) {
- /* WSS is special, as it needs to be ws. */
- pj_cstr(&type_name, "ws");
- } else {
- pj_cstr(&type_name, rdata->tp_info.transport->type_name);
- }
-
- if (!pj_stricmp(&details.uri->transport_param, &type_name)
- && (endpoint->nat.rewrite_contact
- /* Websockets are always rewritten */
- || !pj_stricmp(&details.uri->transport_param,
- pj_cstr(&type_name, "ws")))) {
- /*
- * The contact was rewritten to the reliable transport's
- * source address. Disconnecting the transport for any
- * reason invalidates the contact.
- */
- prune_on_boot = 1;
- }
- }
+ prune_on_boot = !ast_sip_will_uri_survive_restart(details.uri, endpoint, rdata);
contact = ast_sip_location_create_contact(aor, contact_uri,
ast_tvadd(ast_tvnow(), ast_samp2tv(expiration, 1)),
@@ -703,6 +684,21 @@ static void register_aor_core(pjsip_rx_data *rdata,
contact_update->user_agent);
ao2_cleanup(contact_update);
} else {
+ if (contact->prune_on_boot) {
+ struct contact_transport_monitor *monitor;
+ const char *contact_name =
+ ast_sorcery_object_get_id(contact);
+
+ monitor = ast_alloca(sizeof(*monitor) + 2 + strlen(aor_name)
+ + strlen(contact_name));
+ strcpy(monitor->aor_name, aor_name);/* Safe */
+ monitor->contact_name = monitor->aor_name + strlen(aor_name) + 1;
+ strcpy(monitor->contact_name, contact_name);/* Safe */
+
+ ast_sip_transport_monitor_unregister(rdata->tp_info.transport,
+ register_contact_transport_shutdown_cb, monitor, contact_transport_monitor_matcher);
+ }
+
/* We want to report the user agent that was actually in the removed contact */
ast_sip_location_delete_contact(contact);
ast_verb(3, "Removed contact '%s' from AOR '%s' due to request\n", contact_uri, aor_name);
@@ -1091,18 +1087,114 @@ static pjsip_module registrar_module = {
.on_rx_request = registrar_on_rx_request,
};
+/*! \brief Thread keeping things alive */
+static pthread_t check_thread = AST_PTHREADT_NULL;
+
+/*! \brief The global interval at which to check for contact expiration */
+static unsigned int check_interval;
+
+/*! \brief Callback function which deletes a contact */
+static int expire_contact(void *obj, void *arg, int flags)
+{
+ struct ast_sip_contact *contact = obj;
+ struct ast_named_lock *lock;
+
+ lock = ast_named_lock_get(AST_NAMED_LOCK_TYPE_MUTEX, "aor", contact->aor);
+ if (!lock) {
+ return 0;
+ }
+
+ /*
+ * We need to check the expiration again with the aor lock held
+ * in case another thread is attempting to renew the contact.
+ */
+ ao2_lock(lock);
+ if (ast_tvdiff_ms(ast_tvnow(), contact->expiration_time) > 0) {
+ if (contact->prune_on_boot) {
+ struct contact_transport_monitor *monitor;
+ const char *contact_name = ast_sorcery_object_get_id(contact);
+
+ monitor = ast_alloca(sizeof(*monitor) + 2 + strlen(contact->aor)
+ + strlen(contact_name));
+ strcpy(monitor->aor_name, contact->aor);/* Safe */
+ monitor->contact_name = monitor->aor_name + strlen(contact->aor) + 1;
+ strcpy(monitor->contact_name, contact_name);/* Safe */
+
+ ast_sip_transport_monitor_unregister_all(register_contact_transport_shutdown_cb,
+ monitor, contact_transport_monitor_matcher);
+ }
+ ast_sip_location_delete_contact(contact);
+ }
+ ao2_unlock(lock);
+ ast_named_lock_put(lock);
+
+ return 0;
+}
+
+static void *check_expiration_thread(void *data)
+{
+ struct ao2_container *contacts;
+ struct ast_variable *var;
+ char *time = alloca(64);
+
+ while (check_interval) {
+ sleep(check_interval);
+
+ sprintf(time, "%ld", ast_tvnow().tv_sec);
+ var = ast_variable_new("expiration_time <=", time, "");
+
+ ast_debug(4, "Woke up at %s Interval: %d\n", time, check_interval);
+
+ contacts = ast_sorcery_retrieve_by_fields(ast_sip_get_sorcery(), "contact",
+ AST_RETRIEVE_FLAG_MULTIPLE, var);
+
+ ast_variables_destroy(var);
+ if (contacts) {
+ ast_debug(3, "Expiring %d contacts\n", ao2_container_count(contacts));
+ ao2_callback(contacts, OBJ_NODATA, expire_contact, NULL);
+ ao2_ref(contacts, -1);
+ }
+ }
+
+ return NULL;
+}
+
+static void expiration_global_loaded(const char *object_type)
+{
+ check_interval = ast_sip_get_contact_expiration_check_interval();
+
+ /* Observer calls are serialized so this is safe without it's own lock */
+ if (check_interval) {
+ if (check_thread == AST_PTHREADT_NULL) {
+ if (ast_pthread_create_background(&check_thread, NULL, check_expiration_thread, NULL)) {
+ ast_log(LOG_ERROR, "Could not create thread for checking contact expiration.\n");
+ return;
+ }
+ ast_debug(3, "Interval = %d, starting thread\n", check_interval);
+ }
+ } else {
+ if (check_thread != AST_PTHREADT_NULL) {
+ pthread_kill(check_thread, SIGURG);
+ pthread_join(check_thread, NULL);
+ check_thread = AST_PTHREADT_NULL;
+ ast_debug(3, "Interval = 0, shutting thread down\n");
+ }
+ }
+}
+
+/*! \brief Observer which is used to update our interval when the global setting changes */
+static struct ast_sorcery_observer expiration_global_observer = {
+ .loaded = expiration_global_loaded,
+};
+
static int load_module(void)
{
const pj_str_t STR_REGISTER = { "REGISTER", 8 };
- CHECK_PJPROJECT_MODULE_LOADED();
-
ast_pjproject_get_buildopt("PJ_MAX_HOSTNAME", "%d", &pj_max_hostname);
/* As of pjproject 2.4.5, PJSIP_MAX_URL_SIZE isn't exposed yet but we try anyway. */
ast_pjproject_get_buildopt("PJSIP_MAX_URL_SIZE", "%d", &pjsip_max_url_size);
- CHECK_PJSIP_MODULE_LOADED();
-
if (ast_sip_register_service(&registrar_module)) {
return AST_MODULE_LOAD_DECLINE;
}
@@ -1117,15 +1209,28 @@ static int load_module(void)
ast_manager_register_xml(AMI_SHOW_REGISTRATION_CONTACT_STATUSES, EVENT_FLAG_SYSTEM,
ami_show_registration_contact_statuses);
+ ast_sorcery_observer_add(ast_sip_get_sorcery(), "global", &expiration_global_observer);
+ ast_sorcery_reload_object(ast_sip_get_sorcery(), "global");
+
return AST_MODULE_LOAD_SUCCESS;
}
static int unload_module(void)
{
+ if (check_thread != AST_PTHREADT_NULL) {
+ check_interval = 0;
+ pthread_kill(check_thread, SIGURG);
+ pthread_join(check_thread, NULL);
+
+ check_thread = AST_PTHREADT_NULL;
+ }
+
+ ast_sorcery_observer_remove(ast_sip_get_sorcery(), "global", &expiration_global_observer);
+
ast_manager_unregister(AMI_SHOW_REGISTRATIONS);
ast_manager_unregister(AMI_SHOW_REGISTRATION_CONTACT_STATUSES);
ast_sip_unregister_service(&registrar_module);
- ast_sip_transport_monitor_unregister_all(register_contact_transport_shutdown_cb);
+ ast_sip_transport_monitor_unregister_all(register_contact_transport_shutdown_cb, NULL, NULL);
return 0;
}
diff --git a/res/res_pjsip_registrar_expire.c b/res/res_pjsip_registrar_expire.c
deleted file mode 100644
index 85e3fb859..000000000
--- a/res/res_pjsip_registrar_expire.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Asterisk -- An open source telephony toolkit.
- *
- * Copyright (C) 2013, Digium, Inc.
- *
- * Joshua Colp <jcolp@digium.com>
- *
- * See http://www.asterisk.org for more information about
- * the Asterisk project. Please do not directly contact
- * any of the maintainers of this project for assistance;
- * the project provides a web site, mailing lists and IRC
- * channels for your use.
- *
- * This program is free software, distributed under the terms of
- * the GNU General Public License Version 2. See the LICENSE file
- * at the top of the source tree.
- */
-
-/*** MODULEINFO
- <depend>pjproject</depend>
- <depend>res_pjsip</depend>
- <support_level>core</support_level>
- ***/
-
-#include "asterisk.h"
-
-#include <pjsip.h>
-#include <sys/time.h>
-#include <signal.h>
-
-#include "asterisk/res_pjsip.h"
-#include "asterisk/module.h"
-#include "asterisk/named_locks.h"
-
-/*! \brief Thread keeping things alive */
-static pthread_t check_thread = AST_PTHREADT_NULL;
-
-/*! \brief The global interval at which to check for contact expiration */
-static unsigned int check_interval;
-
-/*! \brief Callback function which deletes a contact */
-static int expire_contact(void *obj, void *arg, int flags)
-{
- struct ast_sip_contact *contact = obj;
- struct ast_named_lock *lock;
-
- lock = ast_named_lock_get(AST_NAMED_LOCK_TYPE_MUTEX, "aor", contact->aor);
- if (!lock) {
- return 0;
- }
-
- /*
- * We need to check the expiration again with the aor lock held
- * in case another thread is attempting to renew the contact.
- */
- ao2_lock(lock);
- if (ast_tvdiff_ms(ast_tvnow(), contact->expiration_time) > 0) {
- ast_sip_location_delete_contact(contact);
- }
- ao2_unlock(lock);
- ast_named_lock_put(lock);
-
- return 0;
-}
-
-static void *check_expiration_thread(void *data)
-{
- struct ao2_container *contacts;
- struct ast_variable *var;
- char *time = alloca(64);
-
- while (check_interval) {
- sleep(check_interval);
-
- sprintf(time, "%ld", ast_tvnow().tv_sec);
- var = ast_variable_new("expiration_time <=", time, "");
-
- ast_debug(4, "Woke up at %s Interval: %d\n", time, check_interval);
-
- contacts = ast_sorcery_retrieve_by_fields(ast_sip_get_sorcery(), "contact",
- AST_RETRIEVE_FLAG_MULTIPLE, var);
-
- ast_variables_destroy(var);
- if (contacts) {
- ast_debug(3, "Expiring %d contacts\n", ao2_container_count(contacts));
- ao2_callback(contacts, OBJ_NODATA, expire_contact, NULL);
- ao2_ref(contacts, -1);
- }
- }
-
- return NULL;
-}
-
-static void expiration_global_loaded(const char *object_type)
-{
- check_interval = ast_sip_get_contact_expiration_check_interval();
-
- /* Observer calls are serialized so this is safe without it's own lock */
- if (check_interval) {
- if (check_thread == AST_PTHREADT_NULL) {
- if (ast_pthread_create_background(&check_thread, NULL, check_expiration_thread, NULL)) {
- ast_log(LOG_ERROR, "Could not create thread for checking contact expiration.\n");
- return;
- }
- ast_debug(3, "Interval = %d, starting thread\n", check_interval);
- }
- } else {
- if (check_thread != AST_PTHREADT_NULL) {
- pthread_kill(check_thread, SIGURG);
- pthread_join(check_thread, NULL);
- check_thread = AST_PTHREADT_NULL;
- ast_debug(3, "Interval = 0, shutting thread down\n");
- }
- }
-}
-
-/*! \brief Observer which is used to update our interval when the global setting changes */
-static struct ast_sorcery_observer expiration_global_observer = {
- .loaded = expiration_global_loaded,
-};
-
-static int unload_module(void)
-{
- if (check_thread != AST_PTHREADT_NULL) {
- check_interval = 0;
- pthread_kill(check_thread, SIGURG);
- pthread_join(check_thread, NULL);
-
- check_thread = AST_PTHREADT_NULL;
- }
-
- ast_sorcery_observer_remove(ast_sip_get_sorcery(), "global", &expiration_global_observer);
-
- return 0;
-}
-
-
-static int load_module(void)
-{
- CHECK_PJSIP_MODULE_LOADED();
-
- ast_sorcery_observer_add(ast_sip_get_sorcery(), "global", &expiration_global_observer);
- ast_sorcery_reload_object(ast_sip_get_sorcery(), "global");
-
- return AST_MODULE_LOAD_SUCCESS;
-}
-
-AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PJSIP Contact Auto-Expiration",
- .support_level = AST_MODULE_SUPPORT_CORE,
- .load = load_module,
- .unload = unload_module,
- .load_pri = AST_MODPRI_APP_DEPEND,
- .requires = "res_pjsip",
-);
diff --git a/res/res_pjsip_rfc3326.c b/res/res_pjsip_rfc3326.c
index 8b8035efc..6c02a176c 100644
--- a/res/res_pjsip_rfc3326.c
+++ b/res/res_pjsip_rfc3326.c
@@ -138,8 +138,6 @@ static struct ast_sip_session_supplement rfc3326_supplement = {
static int load_module(void)
{
- CHECK_PJSIP_SESSION_MODULE_LOADED();
-
ast_sip_session_register_supplement(&rfc3326_supplement);
return AST_MODULE_LOAD_SUCCESS;
}
@@ -155,5 +153,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PJSIP RFC3326 Support
.load = load_module,
.unload = unload_module,
.load_pri = AST_MODPRI_APP_DEPEND,
- .requires = "res_pjsip",
+ .requires = "res_pjsip,res_pjsip_session",
);
diff --git a/res/res_pjsip_sdp_rtp.c b/res/res_pjsip_sdp_rtp.c
index 3cc97644a..ce8ed82df 100644
--- a/res/res_pjsip_sdp_rtp.c
+++ b/res/res_pjsip_sdp_rtp.c
@@ -1928,8 +1928,6 @@ static int unload_module(void)
*/
static int load_module(void)
{
- CHECK_PJSIP_SESSION_MODULE_LOADED();
-
if (ast_check_ipv6()) {
ast_sockaddr_parse(&address_rtp, "::", 0);
} else {
diff --git a/res/res_pjsip_send_to_voicemail.c b/res/res_pjsip_send_to_voicemail.c
index 06c3edc03..d68960275 100644
--- a/res/res_pjsip_send_to_voicemail.c
+++ b/res/res_pjsip_send_to_voicemail.c
@@ -215,12 +215,7 @@ static struct ast_sip_session_supplement refer_supplement = {
static int load_module(void)
{
- CHECK_PJSIP_SESSION_MODULE_LOADED();
-
- if (ast_sip_session_register_supplement(&refer_supplement)) {
- ast_log(LOG_ERROR, "Unable to register Send to Voicemail supplement\n");
- return AST_MODULE_LOAD_DECLINE;
- }
+ ast_sip_session_register_supplement(&refer_supplement);
return AST_MODULE_LOAD_SUCCESS;
}
diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c
index 8247fbaaa..5a9134bc7 100644
--- a/res/res_pjsip_session.c
+++ b/res/res_pjsip_session.c
@@ -124,7 +124,7 @@ int ast_sip_session_register_sdp_handler(struct ast_sip_session_sdp_handler *han
}
AST_LIST_INSERT_TAIL(&handler_list->list, handler, next);
ast_debug(1, "Registered SDP stream handler '%s' for stream type '%s'\n", handler->id, stream_type);
- ast_module_ref(ast_module_info->self);
+
return 0;
}
@@ -141,7 +141,7 @@ int ast_sip_session_register_sdp_handler(struct ast_sip_session_sdp_handler *han
return -1;
}
ast_debug(1, "Registered SDP stream handler '%s' for stream type '%s'\n", handler->id, stream_type);
- ast_module_ref(ast_module_info->self);
+
return 0;
}
@@ -156,7 +156,6 @@ static int remove_handler(void *obj, void *arg, void *data, int flags)
if (!strcmp(iter->id, handler->id)) {
AST_LIST_REMOVE_CURRENT(next);
ast_debug(1, "Unregistered SDP stream handler '%s' for stream type '%s'\n", handler->id, stream_type);
- ast_module_unref(ast_module_info->self);
}
}
AST_LIST_TRAVERSE_SAFE_END;
@@ -3426,9 +3425,13 @@ static void handle_incoming_before_media(pjsip_inv_session *inv,
static void session_inv_on_state_changed(pjsip_inv_session *inv, pjsip_event *e)
{
- struct ast_sip_session *session = inv->mod_data[session_module.id];
+ struct ast_sip_session *session;
pjsip_event_id_e type;
+ if (ast_shutdown_final()) {
+ return;
+ }
+
if (e) {
print_debug_details(inv, NULL, e);
type = e->type;
@@ -3436,6 +3439,7 @@ static void session_inv_on_state_changed(pjsip_inv_session *inv, pjsip_event *e)
type = PJSIP_EVENT_UNKNOWN;
}
+ session = inv->mod_data[session_module.id];
if (!session) {
return;
}
@@ -3537,13 +3541,7 @@ static void session_inv_on_tsx_state_changed(pjsip_inv_session *inv, pjsip_trans
struct ast_sip_session *session;
pjsip_tx_data *tdata;
- /*
- * A race condition exists at shutdown where the res_pjsip_session can be
- * unloaded but this callback may still get called afterwards. In this case
- * the id may end up being -1 which is useless to us. To work around this
- * we store the current value and check/use it.
- */
- if (id < 0) {
+ if (ast_shutdown_final()) {
return;
}
@@ -3992,9 +3990,14 @@ static struct pjmedia_sdp_session *create_local_sdp(pjsip_inv_session *inv, stru
static void session_inv_on_rx_offer(pjsip_inv_session *inv, const pjmedia_sdp_session *offer)
{
- struct ast_sip_session *session = inv->mod_data[session_module.id];
+ struct ast_sip_session *session;
pjmedia_sdp_session *answer;
+ if (ast_shutdown_final()) {
+ return;
+ }
+
+ session = inv->mod_data[session_module.id];
if (handle_incoming_sdp(session, offer)) {
return;
}
@@ -4013,9 +4016,14 @@ static void session_inv_on_create_offer(pjsip_inv_session *inv, pjmedia_sdp_sess
static void session_inv_on_media_update(pjsip_inv_session *inv, pj_status_t status)
{
- struct ast_sip_session *session = inv->mod_data[session_module.id];
+ struct ast_sip_session *session;
const pjmedia_sdp_session *local, *remote;
+ if (ast_shutdown_final()) {
+ return;
+ }
+
+ session = inv->mod_data[session_module.id];
if (!session || !session->channel) {
/*
* If we don't have a session or channel then we really
@@ -4038,10 +4046,15 @@ static void session_inv_on_media_update(pjsip_inv_session *inv, pj_status_t stat
static pjsip_redirect_op session_inv_on_redirected(pjsip_inv_session *inv, const pjsip_uri *target, const pjsip_event *e)
{
- struct ast_sip_session *session = inv->mod_data[session_module.id];
+ struct ast_sip_session *session;
const pjsip_sip_uri *uri;
- if (!session->channel) {
+ if (ast_shutdown_final()) {
+ return PJSIP_REDIRECT_STOP;
+ }
+
+ session = inv->mod_data[session_module.id];
+ if (!session || !session->channel) {
return PJSIP_REDIRECT_STOP;
}
@@ -4156,8 +4169,6 @@ static int load_module(void)
{
pjsip_endpoint *endpt;
- CHECK_PJSIP_MODULE_LOADED();
-
if (!ast_sip_get_sorcery() || !ast_sip_get_pjsip_endpoint()) {
return AST_MODULE_LOAD_DECLINE;
}
diff --git a/res/res_pjsip_sips_contact.c b/res/res_pjsip_sips_contact.c
index 41b26df7d..7c0ff4360 100644
--- a/res/res_pjsip_sips_contact.c
+++ b/res/res_pjsip_sips_contact.c
@@ -90,8 +90,6 @@ static int unload_module(void)
static int load_module(void)
{
- CHECK_PJSIP_MODULE_LOADED();
-
if (ast_sip_register_service(&sips_contact_module)) {
return AST_MODULE_LOAD_DECLINE;
}
diff --git a/res/res_pjsip_t38.c b/res/res_pjsip_t38.c
index 7b7cd9910..249472ba9 100644
--- a/res/res_pjsip_t38.c
+++ b/res/res_pjsip_t38.c
@@ -1023,18 +1023,13 @@ static int unload_module(void)
*/
static int load_module(void)
{
- CHECK_PJSIP_SESSION_MODULE_LOADED();
-
if (ast_check_ipv6()) {
ast_sockaddr_parse(&address, "::", 0);
} else {
ast_sockaddr_parse(&address, "0.0.0.0", 0);
}
- if (ast_sip_session_register_supplement(&t38_supplement)) {
- ast_log(LOG_ERROR, "Unable to register T.38 session supplement\n");
- goto end;
- }
+ ast_sip_session_register_supplement(&t38_supplement);
if (ast_sip_session_register_sdp_handler(&image_sdp_handler, "image")) {
ast_log(LOG_ERROR, "Unable to register SDP handler for image stream type\n");
diff --git a/res/res_pjsip_transport_management.c b/res/res_pjsip_transport_management.c
index acffb86dc..afaa24815 100644
--- a/res/res_pjsip_transport_management.c
+++ b/res/res_pjsip_transport_management.c
@@ -323,8 +323,6 @@ static int load_module(void)
{
struct ao2_container *transports;
- CHECK_PJSIP_MODULE_LOADED();
-
transports = ao2_container_alloc(TRANSPORTS_BUCKETS, monitored_transport_hash_fn,
monitored_transport_cmp_fn);
if (!transports) {
diff --git a/res/res_pjsip_transport_websocket.c b/res/res_pjsip_transport_websocket.c
index af1345f35..974b15087 100644
--- a/res/res_pjsip_transport_websocket.c
+++ b/res/res_pjsip_transport_websocket.c
@@ -471,8 +471,6 @@ static struct ast_sip_session_supplement websocket_supplement = {
static int load_module(void)
{
- CHECK_PJSIP_MODULE_LOADED();
-
/*
* We only need one transport type name (ws) defined. Firefox
* and Chrome do not support anything other than secure websockets
@@ -490,10 +488,7 @@ static int load_module(void)
return AST_MODULE_LOAD_DECLINE;
}
- if (ast_sip_session_register_supplement(&websocket_supplement)) {
- ast_sip_unregister_service(&websocket_module);
- return AST_MODULE_LOAD_DECLINE;
- }
+ ast_sip_session_register_supplement(&websocket_supplement);
if (ast_websocket_add_protocol("sip", websocket_cb)) {
ast_sip_session_unregister_supplement(&websocket_supplement);
diff --git a/res/res_pjsip_xpidf_body_generator.c b/res/res_pjsip_xpidf_body_generator.c
index f7c84db3d..7395fd9b7 100644
--- a/res/res_pjsip_xpidf_body_generator.c
+++ b/res/res_pjsip_xpidf_body_generator.c
@@ -148,8 +148,6 @@ static void unregister_all(void)
static int load_module(void)
{
- CHECK_PJSIP_PUBSUB_MODULE_LOADED();
-
if (ast_sip_pubsub_register_body_generator(&xpidf_body_generator)) {
goto fail;
}
diff --git a/res/res_pktccops.c b/res/res_pktccops.c
index 3a12285cb..9beabfb3d 100644
--- a/res/res_pktccops.c
+++ b/res/res_pktccops.c
@@ -1472,9 +1472,6 @@ static int load_module(void)
ast_cli_register_multiple(cli_pktccops, sizeof(cli_pktccops) / sizeof(struct ast_cli_entry));
restart_pktc_thread();
- /* For Optional API. */
- ast_module_shutdown_ref(AST_MODULE_SELF);
-
return 0;
}
diff --git a/res/res_smdi.c b/res/res_smdi.c
index 76e70c274..1d4826a6a 100644
--- a/res/res_smdi.c
+++ b/res/res_smdi.c
@@ -1405,9 +1405,6 @@ static int load_module(void)
ast_custom_function_register(&smdi_msg_retrieve_function);
ast_custom_function_register(&smdi_msg_function);
- /* For Optional API. */
- ast_module_shutdown_ref(AST_MODULE_SELF);
-
return AST_MODULE_LOAD_SUCCESS;
}
diff --git a/res/res_stasis.c b/res/res_stasis.c
index a60ec5fde..dcd74141f 100644
--- a/res/res_stasis.c
+++ b/res/res_stasis.c
@@ -1302,8 +1302,6 @@ static void remove_stasis_end_published(struct ast_channel *chan)
int stasis_app_exec(struct ast_channel *chan, const char *app_name, int argc,
char *argv[])
{
- SCOPED_MODULE_USE(ast_module_info->self);
-
RAII_VAR(struct stasis_app *, app, NULL, ao2_cleanup);
RAII_VAR(struct stasis_app_control *, control, NULL, control_unlink);
struct ast_bridge *bridge = NULL;
@@ -1654,11 +1652,6 @@ void stasis_app_register_event_source(struct stasis_app_event_source *obj)
{
AST_RWLIST_WRLOCK(&event_sources);
AST_LIST_INSERT_TAIL(&event_sources, obj, next);
- /* only need to bump the module ref on non-core sources because the
- core ones are [un]registered by this module. */
- if (!stasis_app_is_core_event_source(obj)) {
- ast_module_ref(ast_module_info->self);
- }
AST_RWLIST_UNLOCK(&event_sources);
}
@@ -1670,9 +1663,6 @@ void stasis_app_unregister_event_source(struct stasis_app_event_source *obj)
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&event_sources, source, next) {
if (source == obj) {
AST_RWLIST_REMOVE_CURRENT(next);
- if (!stasis_app_is_core_event_source(obj)) {
- ast_module_unref(ast_module_info->self);
- }
break;
}
}
@@ -2036,16 +2026,6 @@ enum stasis_app_user_event_res stasis_app_user_event(const char *app_name,
return STASIS_APP_USER_OK;
}
-void stasis_app_ref(void)
-{
- ast_module_ref(ast_module_info->self);
-}
-
-void stasis_app_unref(void)
-{
- ast_module_unref(ast_module_info->self);
-}
-
static int unload_module(void)
{
stasis_app_unregister_event_sources();
diff --git a/res/res_stasis_mailbox.c b/res/res_stasis_mailbox.c
index 3d0e9db69..3f6bede8f 100644
--- a/res/res_stasis_mailbox.c
+++ b/res/res_stasis_mailbox.c
@@ -143,17 +143,11 @@ enum stasis_mailbox_result stasis_app_mailbox_delete(
static int load_module(void)
{
- /* Must be done first */
- ast_mwi_external_ref();
-
return AST_MODULE_LOAD_SUCCESS;
}
static int unload_module(void)
{
- /* Must be done last */
- ast_mwi_external_unref();
-
return 0;
}
diff --git a/res/res_statsd.c b/res/res_statsd.c
index 221b359c9..3e0815218 100644
--- a/res/res_statsd.c
+++ b/res/res_statsd.c
@@ -353,9 +353,6 @@ static int load_module(void)
return AST_MODULE_LOAD_DECLINE;
}
- /* For Optional API. */
- ast_module_shutdown_ref(AST_MODULE_SELF);
-
return AST_MODULE_LOAD_SUCCESS;
}
@@ -381,13 +378,13 @@ static int reload_module(void)
}
}
-/* The priority of this module is set to be as low as possible, since it could
- * be used by any other sort of module.
+/* The priority of this module is set just after realtime, since it loads
+ * configuration and could be used by any other sort of module.
*/
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "Statsd client support",
.support_level = AST_MODULE_SUPPORT_EXTENDED,
.load = load_module,
.unload = unload_module,
.reload = reload_module,
- .load_pri = 0,
+ .load_pri = AST_MODPRI_REALTIME_DRIVER + 5,
);
diff --git a/res/stasis/app.c b/res/stasis/app.c
index 854e79977..18ac7d6ed 100644
--- a/res/stasis/app.c
+++ b/res/stasis/app.c
@@ -1600,13 +1600,6 @@ void stasis_app_register_event_sources(void)
stasis_app_register_event_source(&endpoint_event_source);
}
-int stasis_app_is_core_event_source(struct stasis_app_event_source *obj)
-{
- return obj == &endpoint_event_source ||
- obj == &bridge_event_source ||
- obj == &channel_event_source;
-}
-
void stasis_app_unregister_event_sources(void)
{
stasis_app_unregister_event_source(&endpoint_event_source);
diff --git a/rest-api-templates/res_ari_resource.c.mustache b/rest-api-templates/res_ari_resource.c.mustache
index c1f680f21..67a04d898 100644
--- a/rest-api-templates/res_ari_resource.c.mustache
+++ b/rest-api-templates/res_ari_resource.c.mustache
@@ -40,6 +40,9 @@
<depend type="module">res_ari</depend>
<depend type="module">res_ari_model</depend>
<depend type="module">res_stasis</depend>
+{{#requires_modules}}
+ <depend type="module">{{.}}</depend>
+{{/requires_modules}}
<support_level>core</support_level>
***/
@@ -266,7 +269,6 @@ static int unload_module(void)
ast_ari_websocket_events_event_websocket_dtor();
{{/has_websocket}}
{{/apis}}
- stasis_app_unref();
return 0;
}
@@ -274,43 +276,37 @@ static int load_module(void)
{
int res = 0;
- CHECK_ARI_MODULE_LOADED();
-
{{#apis}}
{{#operations}}
{{#has_websocket}}
- /* This is scoped to not conflict with CHECK_ARI_MODULE_LOADED */
- {
- struct ast_websocket_protocol *protocol;
+ struct ast_websocket_protocol *protocol;
- if (ast_ari_websocket_{{c_name}}_{{c_nickname}}_init() == -1) {
- return AST_MODULE_LOAD_DECLINE;
- }
+ if (ast_ari_websocket_{{c_name}}_{{c_nickname}}_init() == -1) {
+ return AST_MODULE_LOAD_DECLINE;
+ }
- {{full_name}}.ws_server = ast_websocket_server_create();
- if (!{{full_name}}.ws_server) {
- ast_ari_websocket_events_event_websocket_dtor();
- return AST_MODULE_LOAD_DECLINE;
- }
+ {{full_name}}.ws_server = ast_websocket_server_create();
+ if (!{{full_name}}.ws_server) {
+ ast_ari_websocket_events_event_websocket_dtor();
+ return AST_MODULE_LOAD_DECLINE;
+ }
- protocol = ast_websocket_sub_protocol_alloc("{{websocket_protocol}}");
- if (!protocol) {
- ao2_ref({{full_name}}.ws_server, -1);
- {{full_name}}.ws_server = NULL;
- ast_ari_websocket_events_event_websocket_dtor();
- return AST_MODULE_LOAD_DECLINE;
- }
- protocol->session_attempted = ast_ari_{{c_name}}_{{c_nickname}}_ws_attempted_cb;
- protocol->session_established = ast_ari_{{c_name}}_{{c_nickname}}_ws_established_cb;
+ protocol = ast_websocket_sub_protocol_alloc("{{websocket_protocol}}");
+ if (!protocol) {
+ ao2_ref({{full_name}}.ws_server, -1);
+ {{full_name}}.ws_server = NULL;
+ ast_ari_websocket_events_event_websocket_dtor();
+ return AST_MODULE_LOAD_DECLINE;
+ }
+ protocol->session_attempted = ast_ari_{{c_name}}_{{c_nickname}}_ws_attempted_cb;
+ protocol->session_established = ast_ari_{{c_name}}_{{c_nickname}}_ws_established_cb;
{{/has_websocket}}
{{#is_websocket}}
- res |= ast_websocket_server_add_protocol2({{full_name}}.ws_server, protocol);
- }
+ res |= ast_websocket_server_add_protocol2({{full_name}}.ws_server, protocol);
{{/is_websocket}}
{{/operations}}
{{/apis}}
- stasis_app_ref();
res |= ast_ari_add_handler(&{{root_full_name}});
if (res) {
unload_module();
@@ -324,6 +320,6 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - {{{
.support_level = AST_MODULE_SUPPORT_CORE,
.load = load_module,
.unload = unload_module,
- .requires = "res_ari,res_ari_model,res_stasis",
+ .requires = "res_ari,res_ari_model,res_stasis{{#requires_modules}},{{.}}{{/requires_modules}}",
);
{{/api_declaration}}
diff --git a/rest-api-templates/swagger_model.py b/rest-api-templates/swagger_model.py
index 08852415c..3f729d8b5 100644
--- a/rest-api-templates/swagger_model.py
+++ b/rest-api-templates/swagger_model.py
@@ -647,6 +647,7 @@ class ApiDeclaration(Stringify):
self.api_version = api_decl_json.get('apiVersion')
self.base_path = api_decl_json.get('basePath')
self.resource_path = api_decl_json.get('resourcePath')
+ self.requires_modules = api_decl_json.get('requiresModules') or []
api_json = api_decl_json.get('apis') or []
self.apis = [
Api().load(j, processor, context) for j in api_json]
diff --git a/rest-api/api-docs/bridges.json b/rest-api/api-docs/bridges.json
index cf8ee3156..04416c123 100644
--- a/rest-api/api-docs/bridges.json
+++ b/rest-api/api-docs/bridges.json
@@ -6,6 +6,10 @@
"swaggerVersion": "1.1",
"basePath": "http://localhost:8088/ari",
"resourcePath": "/api-docs/bridges.{format}",
+ "requiresModules": [
+ "res_stasis_recording",
+ "res_stasis_playback"
+ ],
"apis": [
{
"path": "/bridges",
diff --git a/rest-api/api-docs/channels.json b/rest-api/api-docs/channels.json
index 602606cfe..ec8bae235 100644
--- a/rest-api/api-docs/channels.json
+++ b/rest-api/api-docs/channels.json
@@ -6,6 +6,12 @@
"swaggerVersion": "1.1",
"basePath": "http://localhost:8088/ari",
"resourcePath": "/api-docs/channels.{format}",
+ "requiresModules": [
+ "res_stasis_answer",
+ "res_stasis_playback",
+ "res_stasis_recording",
+ "res_stasis_snoop"
+ ],
"apis": [
{
"path": "/channels",
diff --git a/rest-api/api-docs/deviceStates.json b/rest-api/api-docs/deviceStates.json
index 94d5b93ce..bd389355c 100644
--- a/rest-api/api-docs/deviceStates.json
+++ b/rest-api/api-docs/deviceStates.json
@@ -6,6 +6,9 @@
"swaggerVersion": "1.1",
"basePath": "http://localhost:8088/ari",
"resourcePath": "/api-docs/deviceStates.{format}",
+ "requiresModules": [
+ "res_stasis_device_state"
+ ],
"apis": [
{
"path": "/deviceStates",
diff --git a/rest-api/api-docs/events.json b/rest-api/api-docs/events.json
index e1b31bb97..d85d8d9fe 100644
--- a/rest-api/api-docs/events.json
+++ b/rest-api/api-docs/events.json
@@ -6,6 +6,9 @@
"swaggerVersion": "1.2",
"basePath": "http://localhost:8088/ari",
"resourcePath": "/api-docs/events.{format}",
+ "requiresModules": [
+ "res_http_websocket"
+ ],
"apis": [
{
"path": "/events",
diff --git a/rest-api/api-docs/mailboxes.json b/rest-api/api-docs/mailboxes.json
index ed50019f5..8f5941b81 100644
--- a/rest-api/api-docs/mailboxes.json
+++ b/rest-api/api-docs/mailboxes.json
@@ -6,6 +6,9 @@
"swaggerVersion": "1.1",
"basePath": "http://localhost:8088/ari",
"resourcePath": "/api-docs/mailboxes.{format}",
+ "requiresModules": [
+ "res_stasis_mailbox"
+ ],
"apis": [
{
"path": "/mailboxes",
diff --git a/rest-api/api-docs/playbacks.json b/rest-api/api-docs/playbacks.json
index 3dc4e1da5..a78dcae71 100644
--- a/rest-api/api-docs/playbacks.json
+++ b/rest-api/api-docs/playbacks.json
@@ -6,6 +6,9 @@
"swaggerVersion": "1.1",
"basePath": "http://localhost:8088/ari",
"resourcePath": "/api-docs/playbacks.{format}",
+ "requiresModules": [
+ "res_stasis_playback"
+ ],
"apis": [
{
"path": "/playbacks/{playbackId}",
diff --git a/rest-api/api-docs/recordings.json b/rest-api/api-docs/recordings.json
index d0b9630da..6ffd6d8e9 100644
--- a/rest-api/api-docs/recordings.json
+++ b/rest-api/api-docs/recordings.json
@@ -6,6 +6,9 @@
"swaggerVersion": "1.1",
"basePath": "http://localhost:8088/ari",
"resourcePath": "/api-docs/recordings.{format}",
+ "requiresModules": [
+ "res_stasis_recording"
+ ],
"apis": [
{
"path": "/recordings/stored",
diff --git a/sounds/Makefile b/sounds/Makefile
index a081c3ccf..779d52a8e 100644
--- a/sounds/Makefile
+++ b/sounds/Makefile
@@ -19,8 +19,8 @@ CMD_PREFIX?=@
SOUNDS_DIR:=$(DESTDIR)$(ASTDATADIR)/sounds
SOUNDS_CACHE_DIR?=
MOH_DIR:=$(DESTDIR)$(ASTDATADIR)/moh
-CORE_SOUNDS_VERSION:=1.6
-EXTRA_SOUNDS_VERSION:=1.5.1
+CORE_SOUNDS_VERSION:=1.6.1
+EXTRA_SOUNDS_VERSION:=1.5.2
MOH_VERSION:=2.03
SOUNDS_URL:=http://downloads.asterisk.org/pub/telephony/sounds/releases
MCS:=$(subst -EN-,-en-,$(MENUSELECT_CORE_SOUNDS))
diff --git a/tests/test_res_pjsip_scheduler.c b/tests/test_res_pjsip_scheduler.c
index 47a7034ff..d0c2d90b5 100644
--- a/tests/test_res_pjsip_scheduler.c
+++ b/tests/test_res_pjsip_scheduler.c
@@ -376,8 +376,6 @@ AST_TEST_DEFINE(scheduler_policy)
static int load_module(void)
{
- CHECK_PJSIP_MODULE_LOADED();
-
AST_TEST_REGISTER(serialized_scheduler);
AST_TEST_REGISTER(unserialized_scheduler);
AST_TEST_REGISTER(scheduler_cleanup);
diff --git a/tests/test_res_stasis.c b/tests/test_res_stasis.c
index 077cc4c7a..2c7906a65 100644
--- a/tests/test_res_stasis.c
+++ b/tests/test_res_stasis.c
@@ -179,13 +179,11 @@ static int unload_module(void)
AST_TEST_UNREGISTER(app_invoke_dne);
AST_TEST_UNREGISTER(app_invoke_one);
AST_TEST_UNREGISTER(app_replaced);
- stasis_app_unref();
return 0;
}
static int load_module(void)
{
- stasis_app_ref();
AST_TEST_REGISTER(app_replaced);
AST_TEST_REGISTER(app_invoke_one);
AST_TEST_REGISTER(app_invoke_dne);
diff --git a/tests/test_utils.c b/tests/test_utils.c
index 68a285727..051fee12b 100644
--- a/tests/test_utils.c
+++ b/tests/test_utils.c
@@ -391,7 +391,7 @@ AST_TEST_DEFINE(agi_loaded_test)
}
#endif
- ast_agi_unregister(ast_module_info->self, &noop_command);
+ ast_agi_unregister(&noop_command);
return res;
}
@@ -646,4 +646,9 @@ static int load_module(void)
return AST_MODULE_LOAD_SUCCESS;
}
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Utils test module");
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Utils test module",
+ .support_level = AST_MODULE_SUPPORT_CORE,
+ .load = load_module,
+ .unload = unload_module,
+ .requires = "res_agi,res_crypto",
+);
diff --git a/tests/test_websocket_client.c b/tests/test_websocket_client.c
index 6743b5369..e33f3f930 100644
--- a/tests/test_websocket_client.c
+++ b/tests/test_websocket_client.c
@@ -156,4 +156,9 @@ static int unload_module(void)
return 0;
}
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Websocket client test module");
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Websocket client test module",
+ .support_level = AST_MODULE_SUPPORT_CORE,
+ .load = load_module,
+ .unload = unload_module,
+ .requires = "res_http_websocket",
+);
diff --git a/utils/check_expr.c b/utils/check_expr.c
index e15705e1b..1e4b9d175 100644
--- a/utils/check_expr.c
+++ b/utils/check_expr.c
@@ -143,13 +143,6 @@ int check_eval(char *buffer, char *error_report);
void parse_file(const char *fname);
int ast_add_profile(const char *x, uint64_t scale) { return 0;}
-int ast_atomic_fetchadd_int_slow(volatile int *p, int v)
-{
- int ret;
- ret = *p;
- *p += v;
- return ret;
-}
char *find_var(const char *varname) /* the list should be pretty short, if there's any list at all */
{