Fossil SCM
Make (refine?) the back-off random delay adjustment to be a factor of the current delay.
Commit
f75fb1dd544f4a3302e872293e63814d5febd43d0462088843588b185f57900f
Parent
d3baf9d5ecffe18…
1 file changed
+4
-5
+4
-5
| --- src/fossil.page.chat.js | ||
| +++ src/fossil.page.chat.js | ||
| @@ -199,21 +199,20 @@ | ||
| 199 | 199 | currentDelay: 1000 /* current polling interval */, |
| 200 | 200 | maxDelay: 60000 /* max interval when backing off for |
| 201 | 201 | connection errors */, |
| 202 | 202 | minDelay: 5000 /* minimum delay time */, |
| 203 | 203 | 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); | |
| 206 | 206 | }, |
| 207 | 207 | incrDelay: function(){ |
| 208 | 208 | if( this.maxDelay > this.currentDelay ){ |
| 209 | 209 | if(this.currentDelay < this.minDelay){ |
| 210 | - this.currentDelay = this.minDelay; | |
| 210 | + this.currentDelay = this.minDelay + this.randomInterval(this.minDelay/2); | |
| 211 | 211 | }else{ |
| 212 | - this.currentDelay *= 2; | |
| 212 | + this.currentDelay = this.currentDelay*2 + this.randomInterval(this.currentDelay/2); | |
| 213 | 213 | } |
| 214 | - this.currentDelay += this.randomInterval(); | |
| 215 | 214 | } |
| 216 | 215 | return this.currentDelay; |
| 217 | 216 | }, |
| 218 | 217 | resetDelay: function(){ |
| 219 | 218 | return this.currentDelay = this.$initialDelay; |
| 220 | 219 |
| --- 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 |