Files
Luc Busquin 91fb928c6e Fix i32 overflow: peers offline 24.9-49.7 days wrongly reported online (#676)
`Duration::as_millis()` returns u128; casting it `as i32` in the
online-status and punch-hole checks keeps only the low 32 bits as a
signed integer. Once a peer has not registered for more than 2^31 ms
(~24.855 days), the value wraps negative and passes the
`elapsed < REG_TIMEOUT` test, so a long-offline peer is reported online
and connection attempts are relayed to its stale socket_addr. The
in-memory peer map is never evicted, so last_reg_time stays frozen until
hbbs restarts, making the false-online window 24.86-49.71 days (and it
repeats every ~49.71 days).

Widen REG_TIMEOUT and the two elapsed casts from i32 to i64 so the
comparison no longer overflows.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-07 10:14:03 +08:00
..
2023-01-06 18:48:18 +09:00
2024-05-24 18:37:11 +08:00
2023-02-08 16:45:30 +08:00
2021-03-19 17:25:58 +08:00