Merge "res_pjsip: disable multi domain to improve realtime performace"

This commit is contained in:
Joshua Colp 2016-04-27 12:45:11 -05:00 committed by Gerrit Code Review
commit d1b9b96456
8 changed files with 115 additions and 36 deletions

View file

@ -279,6 +279,12 @@ res_parking:
for these variables. The indefinite inheritance is also recommended for these variables. The indefinite inheritance is also recommended
for the PARKINGEXTEN variable. for the PARKINGEXTEN variable.
res_pjsip
------------------
* Added new global option (disable_multi_domain) to pjsip.
Disabling Multi Domain can improve realtime performace by reducing
number of database requsts.
chan_pjsip chan_pjsip
------------------ ------------------
* Added 'pjsip show channelstats' CLI command. * Added 'pjsip show channelstats' CLI command.

View file

@ -907,6 +907,11 @@
; (default: "0") ; (default: "0")
;contact_expiration_check_interval=30 ;contact_expiration_check_interval=30
; The interval (in seconds) to check for expired contacts. ; The interval (in seconds) to check for expired contacts.
;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 ;endpoint_identifier_order=ip,username,anonymous
; The order by which endpoint identifiers are given priority. ; The order by which endpoint identifiers are given priority.
; Identifier names are derived from res_pjsip_endpoint_identifier_* ; Identifier names are derived from res_pjsip_endpoint_identifier_*

View file

@ -0,0 +1,31 @@
"""pjsip_add_disable_multi_domain
Revision ID: 8d478ab86e29
Revises: 1c688d9a003c
Create Date: 2016-04-15 11:41:26.988997
"""
# revision identifiers, used by Alembic.
revision = '8d478ab86e29'
down_revision = '1c688d9a003c'
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')

View file

@ -2443,6 +2443,13 @@ unsigned int ast_sip_get_keep_alive_interval(void);
*/ */
unsigned int ast_sip_get_contact_expiration_check_interval(void); unsigned int ast_sip_get_contact_expiration_check_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. * \brief Retrieve the system max initial qualify time.

View file

@ -1294,6 +1294,12 @@
<configOption name="contact_expiration_check_interval" default="30"> <configOption name="contact_expiration_check_interval" default="30">
<synopsis>The interval (in seconds) to check for expired contacts.</synopsis> <synopsis>The interval (in seconds) to check for expired contacts.</synopsis>
</configOption> </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"> <configOption name="max_initial_qualify_time" default="0">
<synopsis>The maximum amount of time from startup that qualifies should be attempted on all contacts. <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> If greater than the qualify_frequency for an aor, qualify_frequency will be used instead.</synopsis>

View file

@ -37,6 +37,7 @@
#define DEFAULT_FROM_USER "asterisk" #define DEFAULT_FROM_USER "asterisk"
#define DEFAULT_REGCONTEXT "" #define DEFAULT_REGCONTEXT ""
#define DEFAULT_CONTACT_EXPIRATION_CHECK_INTERVAL 30 #define DEFAULT_CONTACT_EXPIRATION_CHECK_INTERVAL 30
#define DEFAULT_DISABLE_MULTI_DOMAIN 0
#define DEFAULT_VOICEMAIL_EXTENSION "" #define DEFAULT_VOICEMAIL_EXTENSION ""
static char default_useragent[256]; static char default_useragent[256];
@ -64,6 +65,8 @@ struct global_config {
unsigned int max_initial_qualify_time; unsigned int max_initial_qualify_time;
/* The interval at which to check for expired contacts */ /* The interval at which to check for expired contacts */
unsigned int contact_expiration_check_interval; unsigned int contact_expiration_check_interval;
/*! Nonzero to disable multi domain support */
unsigned int disable_multi_domain;
}; };
static void global_destructor(void *obj) static void global_destructor(void *obj)
@ -222,6 +225,21 @@ unsigned int ast_sip_get_contact_expiration_check_interval(void)
return interval; 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 ast_sip_get_max_initial_qualify_time(void)
{ {
unsigned int time; 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", ast_sorcery_object_field_register(sorcery, "global", "contact_expiration_check_interval",
__stringify(DEFAULT_CONTACT_EXPIRATION_CHECK_INTERVAL), __stringify(DEFAULT_CONTACT_EXPIRATION_CHECK_INTERVAL),
OPT_UINT_T, 0, FLDSET(struct global_config, 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)) { if (ast_sorcery_instance_observer_add(sorcery, &observer_callbacks_global)) {
return -1; return -1;

View file

@ -69,6 +69,7 @@ static struct ast_sip_endpoint *anonymous_identify(pjsip_rx_data *rdata)
return NULL; return NULL;
} }
if (!ast_sip_get_disable_multi_domain()) {
/* Attempt to find the endpoint given the name and domain provided */ /* Attempt to find the endpoint given the name and domain provided */
snprintf(id, sizeof(id), "anonymous@%s", domain_name); snprintf(id, sizeof(id), "anonymous@%s", domain_name);
if ((endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", id))) { 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; goto done;
} }
} }
}
/* Fall back to no domain */ /* Fall back to no domain */
endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", "anonymous"); endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", "anonymous");

View file

@ -69,6 +69,7 @@ static struct ast_sip_endpoint *username_identify(pjsip_rx_data *rdata)
return NULL; return NULL;
} }
if (!ast_sip_get_disable_multi_domain()) {
/* Attempt to find the endpoint given the name and domain provided */ /* Attempt to find the endpoint given the name and domain provided */
snprintf(id, sizeof(id), "%s@%s", endpoint_name, domain_name); snprintf(id, sizeof(id), "%s@%s", endpoint_name, domain_name);
if ((endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", id))) { 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; goto done;
} }
} }
}
/* Fall back to no domain */ /* Fall back to no domain */
endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", endpoint_name); endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", endpoint_name);