File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -130,6 +130,16 @@ impl Timers {
130
130
Some ( last_data_received_without_reply + KEEPALIVE_TIMEOUT )
131
131
}
132
132
133
+ pub ( crate ) fn next_persistent_keepalive ( & self ) -> Option < Instant > {
134
+ let keepalive = Duration :: from_secs ( self . persistent_keepalive as u64 ) ;
135
+
136
+ if keepalive. is_zero ( ) {
137
+ return None ;
138
+ }
139
+
140
+ Some ( self [ TimerName :: TimePersistentKeepalive ] + keepalive)
141
+ }
142
+
133
143
fn is_initiator ( & self ) -> bool {
134
144
self . is_initiator
135
145
}
@@ -378,9 +388,10 @@ impl Tunn {
378
388
}
379
389
380
390
// Persistent KEEPALIVE
381
- if persistent_keepalive > 0
382
- && ( now - self . timers [ TimePersistentKeepalive ]
383
- >= Duration :: from_secs ( persistent_keepalive as _ ) )
391
+ if self
392
+ . timers
393
+ . next_persistent_keepalive ( )
394
+ . is_some_and ( |deadline| now >= deadline)
384
395
{
385
396
tracing:: debug!( "KEEPALIVE(PERSISTENT_KEEPALIVE)" ) ;
386
397
self . timer_tick ( TimePersistentKeepalive , now) ;
@@ -400,7 +411,6 @@ impl Tunn {
400
411
existing. is_none( ) ,
401
412
"Should never override existing handshake"
402
413
) ;
403
-
404
414
tracing:: debug!( ?jitter, "Scheduling new handshake" ) ;
405
415
406
416
return TunnResult :: Done ;
You can’t perform that action at this time.
0 commit comments