Fossil SCM

Make (refine?) the back-off random delay adjustment to be a factor of the current delay.

stephan 2025-04-10 00:28 chat-backoff-timer
Commit f75fb1dd544f4a3302e872293e63814d5febd43d0462088843588b185f57900f
1 file changed +4 -5
--- src/fossil.page.chat.js
+++ src/fossil.page.chat.js
@@ -199,21 +199,20 @@
199199
currentDelay: 1000 /* current polling interval */,
200200
maxDelay: 60000 /* max interval when backing off for
201201
connection errors */,
202202
minDelay: 5000 /* minimum delay time */,
203203
tidReconnect: undefined /*timer id for reconnection determination*/,
204
- randomInterval: function(){
205
- return Math.floor(Math.random() * this.minDelay);
204
+ randomInterval: function(factor){
205
+ return Math.floor(Math.random() * factor);
206206
},
207207
incrDelay: function(){
208208
if( this.maxDelay > this.currentDelay ){
209209
if(this.currentDelay < this.minDelay){
210
- this.currentDelay = this.minDelay;
210
+ this.currentDelay = this.minDelay + this.randomInterval(this.minDelay/2);
211211
}else{
212
- this.currentDelay *= 2;
212
+ this.currentDelay = this.currentDelay*2 + this.randomInterval(this.currentDelay/2);
213213
}
214
- this.currentDelay += this.randomInterval();
215214
}
216215
return this.currentDelay;
217216
},
218217
resetDelay: function(){
219218
return this.currentDelay = this.$initialDelay;
220219
--- src/fossil.page.chat.js
+++ src/fossil.page.chat.js
@@ -199,21 +199,20 @@
199 currentDelay: 1000 /* current polling interval */,
200 maxDelay: 60000 /* max interval when backing off for
201 connection errors */,
202 minDelay: 5000 /* minimum delay time */,
203 tidReconnect: undefined /*timer id for reconnection determination*/,
204 randomInterval: function(){
205 return Math.floor(Math.random() * this.minDelay);
206 },
207 incrDelay: function(){
208 if( this.maxDelay > this.currentDelay ){
209 if(this.currentDelay < this.minDelay){
210 this.currentDelay = this.minDelay;
211 }else{
212 this.currentDelay *= 2;
213 }
214 this.currentDelay += this.randomInterval();
215 }
216 return this.currentDelay;
217 },
218 resetDelay: function(){
219 return this.currentDelay = this.$initialDelay;
220
--- src/fossil.page.chat.js
+++ src/fossil.page.chat.js
@@ -199,21 +199,20 @@
199 currentDelay: 1000 /* current polling interval */,
200 maxDelay: 60000 /* max interval when backing off for
201 connection errors */,
202 minDelay: 5000 /* minimum delay time */,
203 tidReconnect: undefined /*timer id for reconnection determination*/,
204 randomInterval: function(factor){
205 return Math.floor(Math.random() * factor);
206 },
207 incrDelay: function(){
208 if( this.maxDelay > this.currentDelay ){
209 if(this.currentDelay < this.minDelay){
210 this.currentDelay = this.minDelay + this.randomInterval(this.minDelay/2);
211 }else{
212 this.currentDelay = this.currentDelay*2 + this.randomInterval(this.currentDelay/2);
213 }
 
214 }
215 return this.currentDelay;
216 },
217 resetDelay: function(){
218 return this.currentDelay = this.$initialDelay;
219

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button