summaryrefslogtreecommitdiff
path: root/res/res_pjsip/config_global.c
diff options
context:
space:
mode:
authorGeorge Joseph <george.joseph@fairview5.com>2015-04-11 16:04:32 -0600
committerGeorge Joseph <george.joseph@fairview5.com>2015-04-16 16:44:45 -0500
commitc6ed681638f5e481001839712fe2d6d5e1fa526c (patch)
tree4fd654d370e615ad39a22aeeb8ba984445e77de3 /res/res_pjsip/config_global.c
parent51886c68dc13edf127e64218528b077a5f6de967 (diff)
res_pjsip: Add global option to limit the maximum time for initial qualifies
Currently when Asterisk starts initial qualifies of contacts are spread out randomly between 0 and qualify_timeout to prevent network and system overload. If a contact's qualify_frequency is 5 minutes however, that contact may be unavailable to accept calls for the entire 5 minutes after startup. So while staggering the initial qualifies is a good idea, basing the time on qualify_timeout could leave contacts unavailable for too long. This patch adds a new global parameter "max_initial_qualify_time" that sets the maximum time for the initial qualifies. This way you could make sure that all your contacts are initialy, randomly qualified within say 30 seconds but still have the contact's ongoing qualifies at a 5 minute interval. If max_initial_qualify_time is > 0, the formula is initial_interval = min(max_initial_interval, qualify_timeout * random(). If not set, qualify_timeout is used. The default is "0" (disabled). ASTERISK-24863 #close Change-Id: Ib80498aa1ea9923277bef51d6a9015c9c79740f4 Tested-by: George Joseph <george.joseph@fairview5.com>
Diffstat (limited to 'res/res_pjsip/config_global.c')
-rw-r--r--res/res_pjsip/config_global.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/res/res_pjsip/config_global.c b/res/res_pjsip/config_global.c
index 2aa15838f..42ba23487 100644
--- a/res/res_pjsip/config_global.c
+++ b/res/res_pjsip/config_global.c
@@ -33,6 +33,7 @@
#define DEFAULT_OUTBOUND_ENDPOINT "default_outbound_endpoint"
#define DEFAULT_DEBUG "no"
#define DEFAULT_ENDPOINT_IDENTIFIER_ORDER "ip,username,anonymous"
+#define DEFAULT_MAX_INITIAL_QUALIFY_TIME 0
static char default_useragent[256];
@@ -50,6 +51,8 @@ struct global_config {
unsigned int max_forwards;
/* The interval at which to send keep alive messages to active connection-oriented transports */
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)
@@ -161,6 +164,21 @@ unsigned int ast_sip_get_keep_alive_interval(void)
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
* \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",
__stringify(DEFAULT_KEEPALIVE_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)) {
return -1;