@@ -245,20 +245,20 @@ impl BackgroundProcessor {
245
245
channel_manager. timer_tick_occurred ( ) ;
246
246
last_freshness_call = Instant :: now ( ) ;
247
247
}
248
- if await_time. as_secs ( ) > 2 * PING_TIMER {
248
+ if await_time > Duration :: from_secs ( 1 ) {
249
249
// On various platforms, we may be starved of CPU cycles for several reasons.
250
250
// E.g. on iOS, if we've been in the background, we will be entirely paused.
251
251
// Similarly, if we're on a desktop platform and the device has been asleep, we
252
252
// may not get any cycles.
253
- // In any case, if we've been entirely paused for more than double our ping
254
- // timer, we should have disconnected all sockets by now (and they're probably
255
- // dead anyway ).
253
+ // We detect this by checking if our max-100ms-sleep, above, ran longer than a
254
+ // full second, at which point we assume sockets may have been killed (they
255
+ // appear to be at least on some platforms, even if it has only been a second ).
256
256
// Note that we have to take care to not get here just because user event
257
257
// processing was slow at the top of the loop. For example, the sample client
258
258
// may call Bitcoin Core RPCs during event handling, which very often takes
259
259
// more than a handful of seconds to complete, and shouldn't disconnect all our
260
260
// peers.
261
- log_trace ! ( logger, "Awoke after more than double our ping timer , disconnecting peers." ) ;
261
+ log_trace ! ( logger, "100ms sleep took more than a second , disconnecting peers." ) ;
262
262
peer_manager. disconnect_all_peers ( ) ;
263
263
last_ping_call = Instant :: now ( ) ;
264
264
} else if last_ping_call. elapsed ( ) . as_secs ( ) > PING_TIMER {
0 commit comments