mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-24 13:12:03 +00:00
[mod_sofia] Randomize OPTIONS Ping interval
In FS-6400, the attempt was made to randomize OPTIONS packets to be sent at a random interval. The same random interval is applied to all endpoints so this doesn't work. Furthermore, rounding within the code, as well as reseeding with srand() on each run will ultimately make the ping times converge over time. Once the times converge, they will not separate since the reseeding will cause the same random number to apply to each registration. This commmit will apply the random interval only during initial registration and update of registration. All subsequent pings will be incremented with the actual value of ping-mean-interval. (This parameter name is no longer accurate, and would be better named ping-max-interval). srand() has been moved to the start of the worker thread, and all repeat calls have been removed, so that each call of rand(), even during the same second, generates a different random number. Fixes #1132, Fixes #1133
This commit is contained in:
@@ -3755,7 +3755,6 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
||||
|
||||
if ((sub_max_deviation_var = profile->sip_subscription_max_deviation)) {
|
||||
int sub_deviation;
|
||||
srand( (unsigned) ( (unsigned)(intptr_t)switch_thread_self() + switch_micro_time_now() ) );
|
||||
/* random negative number between 0 and negative sub_max_deviation_var: */
|
||||
sub_deviation = ( rand() % sub_max_deviation_var ) - sub_max_deviation_var;
|
||||
if ( (exp_delta + sub_deviation) > 45 ) {
|
||||
|
||||
Reference in New Issue
Block a user