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.
This commit is contained in:
Cobra
2026-04-14 20:40:09 -04:00
parent 7d87f29a47
commit 54b389e767
+6 -7
View File
@@ -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}")