File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed
io/zenoh-transport/src/common Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -167,14 +167,26 @@ impl WaitTime {
167
167
}
168
168
169
169
fn advance ( & mut self , instant : & mut Instant ) {
170
+ // grow wait_time exponentially
171
+ self . wait_time = self . wait_time . saturating_mul ( 2 ) ;
172
+
173
+ // check for waiting limits
170
174
match & mut self . max_wait_time {
175
+ // if we have reached the waiting limit, we do not increase wait instant
176
+ Some ( max_wait_time) if * max_wait_time == Duration :: ZERO => {
177
+ tracing:: trace!( "Backoff increase limit reached" )
178
+ }
179
+ // if the leftover of waiting time is less than next iteration, we select leftover
180
+ Some ( max_wait_time) if * max_wait_time <= self . wait_time => {
181
+ * instant += * max_wait_time;
182
+ * max_wait_time = Duration :: ZERO ;
183
+ }
184
+ // if the leftover of waiting time is bigger than next iteration, select next iteration
171
185
Some ( max_wait_time) => {
172
- if let Some ( new_max_wait_time) = max_wait_time. checked_sub ( self . wait_time ) {
173
- * instant += self . wait_time ;
174
- * max_wait_time = new_max_wait_time;
175
- self . wait_time *= 2 ;
176
- }
186
+ * instant += self . wait_time ;
187
+ * max_wait_time -= self . wait_time ;
177
188
}
189
+ // just select next iteration without checking the upper limit
178
190
None => {
179
191
* instant += self . wait_time ;
180
192
}
You can’t perform that action at this time.
0 commit comments