res_pjsip: disable multi domain to improve realtime performace

This patch added new global pjsip option 'disable_multi_domain'.
Disabling Multi Domain can improve Realtime performance by reducing
number of database requests.

ASTERISK-25930 #close

Change-Id: I2e7160f3aae68475d52742107949a799aa2c7dc7
changes/34/2734/1
Alexei Gradinari 9 years ago committed by George Joseph
parent c69e0f1813
commit c4426f1035

@ -8,6 +8,16 @@
===
==============================================================================
------------------------------------------------------------------------------
--- Functionality changes from Asterisk 13.8.0 to Asterisk 13.9.0 ------------
------------------------------------------------------------------------------
res_pjsip
------------------
* Added new global option (disable_multi_domain) to pjsip.
Disabling Multi Domain can improve realtime performace by reducing
number of database requsts.
------------------------------------------------------------------------------
--- Functionality changes from Asterisk 13.7.0 to Asterisk 13.8.0 ------------
------------------------------------------------------------------------------

@ -886,6 +886,11 @@
;keep_alive_interval=20 ; The interval (in seconds) at which to send keepalive
; messages on all active connection-oriented transports
; (default: "0")
;disable_multi_domain=no
; Disable Multi Domain support.
; If disabled it can improve realtime performace by reducing
; number of database requsts
; (default: "no")
;endpoint_identifier_order=ip,username,anonymous
; The order by which endpoint identifiers are given priority.
; Identifier names are derived from res_pjsip_endpoint_identifier_*

@ -0,0 +1,31 @@
"""pjsip_add_disable_multi_domain
Revision ID: 8d478ab86e29
Revises: 3bcc0b5bc2c9
Create Date: 2016-04-15 11:41:26.988997
"""
# revision identifiers, used by Alembic.
revision = '8d478ab86e29'
down_revision = '3bcc0b5bc2c9'
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_globals', sa.Column('disable_multi_domain', yesno_values))
def downgrade():
op.drop_column('ps_globals', 'disable_multi_domain')

@ -2192,6 +2192,14 @@ void ast_sip_get_default_from_user(char *from_user, size_t size);
*/
unsigned int ast_sip_get_keep_alive_interval(void);
/*!
* \brief Retrieve the system setting 'disable multi domain'.
* \since 13.9.0
*
* \retval non zero if disable multi domain.
*/
unsigned int ast_sip_get_disable_multi_domain(void);
/*!
* \brief Retrieve the system max initial qualify time.
*

@ -1279,6 +1279,12 @@
<configOption name="keep_alive_interval" default="0">
<synopsis>The interval (in seconds) to send keepalives to active connection-oriented transports.</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>

@ -36,6 +36,7 @@
#define DEFAULT_MAX_INITIAL_QUALIFY_TIME 0
#define DEFAULT_FROM_USER "asterisk"
#define DEFAULT_REGCONTEXT ""
#define DEFAULT_DISABLE_MULTI_DOMAIN 0
static char default_useragent[256];
@ -58,6 +59,8 @@ struct global_config {
unsigned int keep_alive_interval;
/* The maximum time for all contacts to be qualified at startup */
unsigned int max_initial_qualify_time;
/*! Nonzero to disable multi domain support */
unsigned int disable_multi_domain;
};
static void global_destructor(void *obj)
@ -186,6 +189,21 @@ unsigned int ast_sip_get_keep_alive_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;
@ -331,7 +349,8 @@ int ast_sip_initialize_sorcery_global(void)
OPT_STRINGFIELD_T, 0, STRFLDSET(struct global_config, default_from_user));
ast_sorcery_object_field_register(sorcery, "global", "regcontext", DEFAULT_REGCONTEXT,
OPT_STRINGFIELD_T, 0, STRFLDSET(struct global_config, regcontext));
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,6 +69,7 @@ static struct ast_sip_endpoint *anonymous_identify(pjsip_rx_data *rdata)
return NULL;
}
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))) {
@ -93,6 +94,7 @@ static struct ast_sip_endpoint *anonymous_identify(pjsip_rx_data *rdata)
goto done;
}
}
}
/* Fall back to no domain */
endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", "anonymous");

@ -69,6 +69,7 @@ static struct ast_sip_endpoint *username_identify(pjsip_rx_data *rdata)
return NULL;
}
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))) {
@ -93,6 +94,7 @@ static struct ast_sip_endpoint *username_identify(pjsip_rx_data *rdata)
goto done;
}
}
}
/* Fall back to no domain */
endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", endpoint_name);

Loading…
Cancel
Save