@@ -245,20 +245,20 @@ impl BackgroundProcessor {
245245 channel_manager. timer_tick_occurred ( ) ;
246246 last_freshness_call = Instant :: now ( ) ;
247247 }
248- if await_time. as_secs ( ) > 2 * PING_TIMER {
248+ if await_time > Duration :: from_secs ( 1 ) {
249249 // On various platforms, we may be starved of CPU cycles for several reasons.
250250 // E.g. on iOS, if we've been in the background, we will be entirely paused.
251251 // Similarly, if we're on a desktop platform and the device has been asleep, we
252252 // 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 ).
256256 // Note that we have to take care to not get here just because user event
257257 // processing was slow at the top of the loop. For example, the sample client
258258 // may call Bitcoin Core RPCs during event handling, which very often takes
259259 // more than a handful of seconds to complete, and shouldn't disconnect all our
260260 // 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." ) ;
262262 peer_manager. disconnect_all_peers ( ) ;
263263 last_ping_call = Instant :: now ( ) ;
264264 } else if last_ping_call. elapsed ( ) . as_secs ( ) > PING_TIMER {
0 commit comments