From c7eb1ee14f2f46bdeac2fbb26ac8dd9383b536bf Mon Sep 17 00:00:00 2001 From: Cobra Date: Tue, 14 Apr 2026 20:40:09 -0400 Subject: [PATCH] Prevent watchdog from re-triggering departure on already-departing devices Repeated watchdog calls for a device already in departing=True state were feeding the churn suppressor, which misclassified the iPhone's IP as infrastructure after 3 calls within 30 min. This blocked all subsequent departure processing and caused a 31-min alert delay. Fix: gate the on_departure() call on a should_depart flag set only when the device is known and not already departing. --- net_alerter/net_alerter.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/net_alerter/net_alerter.py b/net_alerter/net_alerter.py index 9c819e6..a090ca4 100644 --- a/net_alerter/net_alerter.py +++ b/net_alerter/net_alerter.py @@ -1787,15 +1787,14 @@ def personal_watchdog() -> None: # Check if device is silent if now - ts > WATCHDOG_TIMEOUT_SEC: # Only fire if device is currently known and not already departing - # Don't hold lock when calling on_departure + should_depart = False with known_lock: if mac in known_devices and not known_devices[mac].get('departing'): - # Copy the device info before releasing lock - dev_info = known_devices[mac].copy() - - # Fire departure outside the lock - logging.info(f"Watchdog: personal device {mac} silent >{WATCHDOG_TIMEOUT_SEC}s, triggering departure") - on_departure(mac) + should_depart = True + + if should_depart: + logging.info(f"Watchdog: personal device {mac} silent >{WATCHDOG_TIMEOUT_SEC}s, triggering departure") + on_departure(mac) except Exception as e: logging.error(f"Watchdog thread error: {e}")