Repository navigation
fix(pjsua): honour the retry interval when it is below the jitter #5319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5467,8 +5467,9 @@ static void auto_rereg_timer_cb(pj_timer_heap_t *th, pj_timer_entry *te) | |
| } | ||
|
|
||
|
|
||
| /* Schedule reregistration for specified account. Note that the first | ||
| * re-registration after a registration failure will be done immediately. | ||
| /* Schedule reregistration for specified account. Until a registration | ||
| * succeeds again, the first retry waits reg_first_retry_interval and later | ||
| * ones reg_retry_interval, both randomized by reg_retry_random_interval. | ||
| * Also note that this function should be called within PJSUA mutex. | ||
| */ | ||
| static void schedule_reregistration(pjsua_acc *acc) | ||
|
|
@@ -5516,19 +5517,27 @@ static void schedule_reregistration(pjsua_acc *acc) | |
| acc->auto_rereg.timer.cb = &auto_rereg_timer_cb; | ||
| acc->auto_rereg.timer.user_data = acc; | ||
|
|
||
| /* Reregistration attempt. The first attempt will be done immediately. */ | ||
| /* Reregistration attempt. The first one since the last successful | ||
| * registration waits reg_first_retry_interval. | ||
| */ | ||
| delay.sec = acc->auto_rereg.attempt_cnt? acc->cfg.reg_retry_interval : | ||
| acc->cfg.reg_first_retry_interval; | ||
| delay.msec = 0; | ||
|
|
||
| /* Randomize interval by +/- reg_retry_random_interval, if configured */ | ||
| /* Randomize interval by +/- reg_retry_random_interval, if configured. | ||
| * The lower bound is clamped at 0: an interval shorter than that gives | ||
| * a delay between 0 and the interval plus reg_retry_random_interval. | ||
| */ | ||
| if (acc->cfg.reg_retry_random_interval) { | ||
| long rand_ms = acc->cfg.reg_retry_random_interval * 1000; | ||
| if (delay.sec >= (long)acc->cfg.reg_retry_random_interval) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Two nearby comments no longer match the behaviour (both lines are outside the diff, so I'm commenting here):
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both fixed in 0e1ad28. The randomisation comment now says the lower bound is clamped at 0 and gives the resulting range for an interval below |
||
| delay.msec = -rand_ms + (pj_rand() % (rand_ms * 2)); | ||
| } else { | ||
| delay.sec = 0; | ||
| /* A huge unsigned interval may not fit in a long */ | ||
| if (delay.sec < 0) | ||
| delay.sec = 0; | ||
| delay.msec = (pj_rand() % (delay.sec * 1000 + rand_ms)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The divisor now depends on It's an odd config, but the guard is cheap. Could you clamp
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right that this is new: the divisor used to be |
||
| delay.sec = 0; | ||
| } | ||
| } | ||
| pj_time_val_normalize(&delay); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for documenting the new window here. The
reg_retry_interval(L5147) andreg_first_retry_interval(L5161) docs still say the interval is "randomized slightly by some seconds", though, and with this change a 1 s interval can become anything from 0 to 11 s. Could you update those two to point to the clamped window described here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 0e1ad28: both now say the interval is randomized by
reg_retry_random_intervaland point there for the resulting range, rather than repeating it. The pjsua2retryIntervalSecandfirstRetryIntervalSecdocs got the same change, and pjsip/pjproject_docs#70 addsreg_retry_random_intervalto the retry settings listed in the server affinity guide.