mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-02 10:22:46 +00:00
Merge "res_pjsip: Add global option to limit the maximum time for initial qualifies" into 13
This commit is contained in:
4
CHANGES
4
CHANGES
@@ -28,6 +28,10 @@ res_pjsip
|
|||||||
* A new CLI command has been added: "pjsip show settings", which shows
|
* A new CLI command has been added: "pjsip show settings", which shows
|
||||||
both the global and system configuration settings.
|
both the global and system configuration settings.
|
||||||
|
|
||||||
|
* A new global option has been added: "max_initial_qualify_time", which
|
||||||
|
sets the maximum amount of time from startup that qualifies should be
|
||||||
|
attempted on all contacts.
|
||||||
|
|
||||||
res_ari_channels
|
res_ari_channels
|
||||||
------------------
|
------------------
|
||||||
* Two new events, 'ChannelHold' and 'ChannelUnhold', have been added to the
|
* Two new events, 'ChannelHold' and 'ChannelUnhold', have been added to the
|
||||||
|
@@ -859,7 +859,10 @@
|
|||||||
; 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_*
|
||||||
; modules. (default: ip,username,anonymous)
|
; modules. (default: ip,username,anonymous)
|
||||||
|
;max_initial_qualify_time=4 ; The maximum amount of time (in seconds) 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.
|
||||||
|
|
||||||
; MODULE PROVIDING BELOW SECTION(S): res_pjsip_acl
|
; MODULE PROVIDING BELOW SECTION(S): res_pjsip_acl
|
||||||
;==========================ACL SECTION OPTIONS=========================
|
;==========================ACL SECTION OPTIONS=========================
|
||||||
|
@@ -0,0 +1,20 @@
|
|||||||
|
"""add pjsip max_initial_qualify_time
|
||||||
|
|
||||||
|
Revision ID: a541e0b5e89
|
||||||
|
Revises: 461d7d691209
|
||||||
|
Create Date: 2015-04-15 14:37:36.424471
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = 'a541e0b5e89'
|
||||||
|
down_revision = '461d7d691209'
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
op.add_column('ps_globals', sa.Column('max_initial_qualify_time', sa.Integer))
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
op.drop_column('ps_globals', 'max_initial_qualify_time')
|
@@ -1954,4 +1954,12 @@ char *ast_sip_get_endpoint_identifier_order(void);
|
|||||||
*/
|
*/
|
||||||
unsigned int ast_sip_get_keep_alive_interval(void);
|
unsigned int ast_sip_get_keep_alive_interval(void);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Retrieve the system max initial qualify time.
|
||||||
|
*
|
||||||
|
* \retval the maximum initial qualify time.
|
||||||
|
*/
|
||||||
|
unsigned int ast_sip_get_max_initial_qualify_time(void);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _RES_PJSIP_H */
|
#endif /* _RES_PJSIP_H */
|
||||||
|
@@ -1208,6 +1208,10 @@
|
|||||||
<configOption name="keep_alive_interval" default="0">
|
<configOption name="keep_alive_interval" default="0">
|
||||||
<synopsis>The interval (in seconds) to send keepalives to active connection-oriented transports.</synopsis>
|
<synopsis>The interval (in seconds) to send keepalives to active connection-oriented transports.</synopsis>
|
||||||
</configOption>
|
</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>
|
||||||
|
</configOption>
|
||||||
<configOption name="type">
|
<configOption name="type">
|
||||||
<synopsis>Must be of type 'global'.</synopsis>
|
<synopsis>Must be of type 'global'.</synopsis>
|
||||||
</configOption>
|
</configOption>
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
#define DEFAULT_OUTBOUND_ENDPOINT "default_outbound_endpoint"
|
#define DEFAULT_OUTBOUND_ENDPOINT "default_outbound_endpoint"
|
||||||
#define DEFAULT_DEBUG "no"
|
#define DEFAULT_DEBUG "no"
|
||||||
#define DEFAULT_ENDPOINT_IDENTIFIER_ORDER "ip,username,anonymous"
|
#define DEFAULT_ENDPOINT_IDENTIFIER_ORDER "ip,username,anonymous"
|
||||||
|
#define DEFAULT_MAX_INITIAL_QUALIFY_TIME 0
|
||||||
|
|
||||||
static char default_useragent[256];
|
static char default_useragent[256];
|
||||||
|
|
||||||
@@ -50,6 +51,8 @@ struct global_config {
|
|||||||
unsigned int max_forwards;
|
unsigned int max_forwards;
|
||||||
/* The interval at which to send keep alive messages to active connection-oriented transports */
|
/* The interval at which to send keep alive messages to active connection-oriented transports */
|
||||||
unsigned int keep_alive_interval;
|
unsigned int keep_alive_interval;
|
||||||
|
/* The maximum time for all contacts to be qualified at startup */
|
||||||
|
unsigned int max_initial_qualify_time;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void global_destructor(void *obj)
|
static void global_destructor(void *obj)
|
||||||
@@ -161,6 +164,21 @@ unsigned int ast_sip_get_keep_alive_interval(void)
|
|||||||
return interval;
|
return interval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int ast_sip_get_max_initial_qualify_time(void)
|
||||||
|
{
|
||||||
|
unsigned int time;
|
||||||
|
struct global_config *cfg;
|
||||||
|
|
||||||
|
cfg = get_global_cfg();
|
||||||
|
if (!cfg) {
|
||||||
|
return DEFAULT_MAX_INITIAL_QUALIFY_TIME;
|
||||||
|
}
|
||||||
|
|
||||||
|
time = cfg->max_initial_qualify_time;
|
||||||
|
ao2_ref(cfg, -1);
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \internal
|
* \internal
|
||||||
* \brief Observer to set default global object if none exist.
|
* \brief Observer to set default global object if none exist.
|
||||||
@@ -271,6 +289,9 @@ int ast_sip_initialize_sorcery_global(void)
|
|||||||
ast_sorcery_object_field_register(sorcery, "global", "keep_alive_interval",
|
ast_sorcery_object_field_register(sorcery, "global", "keep_alive_interval",
|
||||||
__stringify(DEFAULT_KEEPALIVE_INTERVAL),
|
__stringify(DEFAULT_KEEPALIVE_INTERVAL),
|
||||||
OPT_UINT_T, 0, FLDSET(struct global_config, keep_alive_interval));
|
OPT_UINT_T, 0, FLDSET(struct global_config, keep_alive_interval));
|
||||||
|
ast_sorcery_object_field_register(sorcery, "global", "max_initial_qualify_time",
|
||||||
|
__stringify(DEFAULT_MAX_INITIAL_QUALIFY_TIME),
|
||||||
|
OPT_UINT_T, 0, FLDSET(struct global_config, max_initial_qualify_time));
|
||||||
|
|
||||||
if (ast_sorcery_instance_observer_add(sorcery, &observer_callbacks_global)) {
|
if (ast_sorcery_instance_observer_add(sorcery, &observer_callbacks_global)) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@@ -949,13 +949,19 @@ static int qualify_and_schedule_cb(void *obj, void *arg, int flags)
|
|||||||
struct ast_sip_contact *contact = obj;
|
struct ast_sip_contact *contact = obj;
|
||||||
struct ast_sip_aor *aor = arg;
|
struct ast_sip_aor *aor = arg;
|
||||||
int initial_interval;
|
int initial_interval;
|
||||||
|
int max_time = ast_sip_get_max_initial_qualify_time();
|
||||||
|
|
||||||
contact->qualify_frequency = aor->qualify_frequency;
|
contact->qualify_frequency = aor->qualify_frequency;
|
||||||
contact->authenticate_qualify = aor->authenticate_qualify;
|
contact->authenticate_qualify = aor->authenticate_qualify;
|
||||||
|
|
||||||
/* Delay initial qualification by a random fraction of the specified interval */
|
/* Delay initial qualification by a random fraction of the specified interval */
|
||||||
initial_interval = contact->qualify_frequency * 1000;
|
if (max_time && max_time < contact->qualify_frequency) {
|
||||||
initial_interval = (int)(initial_interval * ast_random_double());
|
initial_interval = max_time;
|
||||||
|
} else {
|
||||||
|
initial_interval = contact->qualify_frequency;
|
||||||
|
}
|
||||||
|
|
||||||
|
initial_interval = (int)((initial_interval * 1000) * ast_random_double());
|
||||||
|
|
||||||
if (contact->qualify_frequency) {
|
if (contact->qualify_frequency) {
|
||||||
schedule_qualify(contact, initial_interval);
|
schedule_qualify(contact, initial_interval);
|
||||||
|
Reference in New Issue
Block a user