mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
Merge "res_pjsip: disable multi domain to improve realtime performace" into 13
This commit is contained in:
@@ -1291,6 +1291,12 @@
|
||||
<configOption name="contact_expiration_check_interval" default="30">
|
||||
<synopsis>The interval (in seconds) to check for expired contacts.</synopsis>
|
||||
</configOption>
|
||||
<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.
|
||||
</para></description>
|
||||
</configOption>
|
||||
<configOption name="max_initial_qualify_time" default="0">
|
||||
<synopsis>The maximum amount of time from startup that qualifies should be attempted on all contacts.
|
||||
If greater than the qualify_frequency for an aor, qualify_frequency will be used instead.</synopsis>
|
||||
|
@@ -37,6 +37,7 @@
|
||||
#define DEFAULT_FROM_USER "asterisk"
|
||||
#define DEFAULT_REGCONTEXT ""
|
||||
#define DEFAULT_CONTACT_EXPIRATION_CHECK_INTERVAL 30
|
||||
#define DEFAULT_DISABLE_MULTI_DOMAIN 0
|
||||
#define DEFAULT_VOICEMAIL_EXTENSION ""
|
||||
|
||||
static char default_useragent[256];
|
||||
@@ -64,6 +65,8 @@ struct global_config {
|
||||
unsigned int max_initial_qualify_time;
|
||||
/* The interval at which to check for expired contacts */
|
||||
unsigned int contact_expiration_check_interval;
|
||||
/*! Nonzero to disable multi domain support */
|
||||
unsigned int disable_multi_domain;
|
||||
};
|
||||
|
||||
static void global_destructor(void *obj)
|
||||
@@ -222,6 +225,21 @@ unsigned int ast_sip_get_contact_expiration_check_interval(void)
|
||||
return interval;
|
||||
}
|
||||
|
||||
unsigned int ast_sip_get_disable_multi_domain(void)
|
||||
{
|
||||
unsigned int disable_multi_domain;
|
||||
struct global_config *cfg;
|
||||
|
||||
cfg = get_global_cfg();
|
||||
if (!cfg) {
|
||||
return DEFAULT_DISABLE_MULTI_DOMAIN;
|
||||
}
|
||||
|
||||
disable_multi_domain = cfg->disable_multi_domain;
|
||||
ao2_ref(cfg, -1);
|
||||
return disable_multi_domain;
|
||||
}
|
||||
|
||||
unsigned int ast_sip_get_max_initial_qualify_time(void)
|
||||
{
|
||||
unsigned int time;
|
||||
@@ -373,6 +391,8 @@ int ast_sip_initialize_sorcery_global(void)
|
||||
ast_sorcery_object_field_register(sorcery, "global", "contact_expiration_check_interval",
|
||||
__stringify(DEFAULT_CONTACT_EXPIRATION_CHECK_INTERVAL),
|
||||
OPT_UINT_T, 0, FLDSET(struct global_config, contact_expiration_check_interval));
|
||||
ast_sorcery_object_field_register(sorcery, "global", "disable_multi_domain", "no",
|
||||
OPT_BOOL_T, 1, FLDSET(struct global_config, disable_multi_domain));
|
||||
|
||||
if (ast_sorcery_instance_observer_add(sorcery, &observer_callbacks_global)) {
|
||||
return -1;
|
||||
|
@@ -69,28 +69,30 @@ static struct ast_sip_endpoint *anonymous_identify(pjsip_rx_data *rdata)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Attempt to find the endpoint given the name and domain provided */
|
||||
snprintf(id, sizeof(id), "anonymous@%s", domain_name);
|
||||
if ((endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", id))) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* See if an alias exists for the domain provided */
|
||||
if ((alias = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "domain_alias", domain_name))) {
|
||||
snprintf(id, sizeof(id), "anonymous@%s", alias->domain);
|
||||
if (!ast_sip_get_disable_multi_domain()) {
|
||||
/* Attempt to find the endpoint given the name and domain provided */
|
||||
snprintf(id, sizeof(id), "anonymous@%s", domain_name);
|
||||
if ((endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", id))) {
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
/* See if the transport this came in on has a provided domain */
|
||||
if ((transport_states = ast_sip_get_transport_states())
|
||||
&& (transport_state = ao2_callback(transport_states, 0, find_transport_state_in_use, rdata))
|
||||
&& (transport = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "transport", transport_state->id))
|
||||
&& !ast_strlen_zero(transport->domain)) {
|
||||
snprintf(id, sizeof(id), "anonymous@%s", transport->domain);
|
||||
if ((endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", id))) {
|
||||
goto done;
|
||||
/* See if an alias exists for the domain provided */
|
||||
if ((alias = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "domain_alias", domain_name))) {
|
||||
snprintf(id, sizeof(id), "anonymous@%s", alias->domain);
|
||||
if ((endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", id))) {
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
/* See if the transport this came in on has a provided domain */
|
||||
if ((transport_states = ast_sip_get_transport_states())
|
||||
&& (transport_state = ao2_callback(transport_states, 0, find_transport_state_in_use, rdata))
|
||||
&& (transport = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "transport", transport_state->id))
|
||||
&& !ast_strlen_zero(transport->domain)) {
|
||||
snprintf(id, sizeof(id), "anonymous@%s", transport->domain);
|
||||
if ((endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", id))) {
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -69,28 +69,30 @@ static struct ast_sip_endpoint *username_identify(pjsip_rx_data *rdata)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Attempt to find the endpoint given the name and domain provided */
|
||||
snprintf(id, sizeof(id), "%s@%s", endpoint_name, domain_name);
|
||||
if ((endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", id))) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* See if an alias exists for the domain provided */
|
||||
if ((alias = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "domain_alias", domain_name))) {
|
||||
snprintf(id, sizeof(id), "%s@%s", endpoint_name, alias->domain);
|
||||
if (!ast_sip_get_disable_multi_domain()) {
|
||||
/* Attempt to find the endpoint given the name and domain provided */
|
||||
snprintf(id, sizeof(id), "%s@%s", endpoint_name, domain_name);
|
||||
if ((endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", id))) {
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
/* See if the transport this came in on has a provided domain */
|
||||
if ((transport_states = ast_sip_get_transport_states())
|
||||
&& (transport_state = ao2_callback(transport_states, 0, find_transport_state_in_use, rdata))
|
||||
&& (transport = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "transport", transport_state->id))
|
||||
&& !ast_strlen_zero(transport->domain)) {
|
||||
snprintf(id, sizeof(id), "anonymous@%s", transport->domain);
|
||||
if ((endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", id))) {
|
||||
goto done;
|
||||
/* See if an alias exists for the domain provided */
|
||||
if ((alias = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "domain_alias", domain_name))) {
|
||||
snprintf(id, sizeof(id), "%s@%s", endpoint_name, alias->domain);
|
||||
if ((endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", id))) {
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
/* See if the transport this came in on has a provided domain */
|
||||
if ((transport_states = ast_sip_get_transport_states())
|
||||
&& (transport_state = ao2_callback(transport_states, 0, find_transport_state_in_use, rdata))
|
||||
&& (transport = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "transport", transport_state->id))
|
||||
&& !ast_strlen_zero(transport->domain)) {
|
||||
snprintf(id, sizeof(id), "anonymous@%s", transport->domain);
|
||||
if ((endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", id))) {
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user