summaryrefslogtreecommitdiff
path: root/pjsip
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2011-09-21 07:38:22 +0000
committerBenny Prijono <bennylp@teluu.com>2011-09-21 07:38:22 +0000
commit1ae52d9602a72858cd1076a8b11bbeaecb1f8165 (patch)
tree0e9f433749d6a3742b023ee24c7c9688d76d653e /pjsip
parentc03b900af9d3c1e4f52540ec580f29b4903f8417 (diff)
Added option to control first re-registration retry interval. This closes #1375
git-svn-id: http://svn.pjsip.org/repos/pjproject/branches/1.x@3762 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip')
-rw-r--r--pjsip/include/pjsua-lib/pjsua.h17
-rw-r--r--pjsip/src/pjsua-lib/pjsua_acc.c13
2 files changed, 28 insertions, 2 deletions
diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h
index fe8ccc08..40c4e27d 100644
--- a/pjsip/include/pjsua-lib/pjsua.h
+++ b/pjsip/include/pjsua-lib/pjsua.h
@@ -2519,13 +2519,28 @@ typedef struct pjsua_acc_config
/**
* Specify interval of auto registration retry upon registration failure
* (including caused by transport problem), in second. Set to 0 to
- * disable auto re-registration.
+ * disable auto re-registration. Note that if the registration retry
+ * occurs because of transport failure, the first retry will be done
+ * after \a reg_first_retry_interval seconds instead. Also note that
+ * the interval will be randomized slightly by approximately +/- ten
+ * seconds to avoid all clients re-registering at the same time.
+ *
+ * See also \a reg_first_retry_interval setting.
*
* Default: #PJSUA_REG_RETRY_INTERVAL
*/
unsigned reg_retry_interval;
/**
+ * This specifies the interval for the first registration retry. The
+ * registration retry is explained in \a reg_retry_interval. Note that
+ * the value here will also be randomized by +/- ten seconds.
+ *
+ * Default: 0
+ */
+ unsigned reg_first_retry_interval;
+
+ /**
* Specify whether calls of the configured account should be dropped
* after registration failure and an attempt of re-registration has
* also failed.
diff --git a/pjsip/src/pjsua-lib/pjsua_acc.c b/pjsip/src/pjsua-lib/pjsua_acc.c
index 851a6f11..e1f73bdf 100644
--- a/pjsip/src/pjsua-lib/pjsua_acc.c
+++ b/pjsip/src/pjsua-lib/pjsua_acc.c
@@ -2752,8 +2752,19 @@ static void schedule_reregistration(pjsua_acc *acc)
acc->auto_rereg.timer.user_data = acc;
/* Reregistration attempt. The first attempt will be done immediately. */
- delay.sec = acc->auto_rereg.attempt_cnt? acc->cfg.reg_retry_interval : 0;
+ delay.sec = acc->auto_rereg.attempt_cnt? acc->cfg.reg_retry_interval :
+ acc->cfg.reg_first_retry_interval;
delay.msec = 0;
+
+ /* Randomize interval by +/- 10 secs */
+ if (delay.sec >= 10) {
+ delay.msec = -10000 + (pj_rand() % 20000);
+ } else {
+ delay.sec = 0;
+ delay.msec = (pj_rand() % 10000);
+ }
+ pj_time_val_normalize(&delay);
+
pjsua_schedule_timer(&acc->auto_rereg.timer, &delay);
}