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:
@@ -1787,15 +1787,14 @@ def personal_watchdog() -> None:
|
|||||||
# Check if device is silent
|
# Check if device is silent
|
||||||
if now - ts > WATCHDOG_TIMEOUT_SEC:
|
if now - ts > WATCHDOG_TIMEOUT_SEC:
|
||||||
# Only fire if device is currently known and not already departing
|
# 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:
|
with known_lock:
|
||||||
if mac in known_devices and not known_devices[mac].get('departing'):
|
if mac in known_devices and not known_devices[mac].get('departing'):
|
||||||
# Copy the device info before releasing lock
|
should_depart = True
|
||||||
dev_info = known_devices[mac].copy()
|
|
||||||
|
|
||||||
# Fire departure outside the lock
|
if should_depart:
|
||||||
logging.info(f"Watchdog: personal device {mac} silent >{WATCHDOG_TIMEOUT_SEC}s, triggering departure")
|
logging.info(f"Watchdog: personal device {mac} silent >{WATCHDOG_TIMEOUT_SEC}s, triggering departure")
|
||||||
on_departure(mac)
|
on_departure(mac)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Watchdog thread error: {e}")
|
logging.error(f"Watchdog thread error: {e}")
|
||||||
|
|||||||
Reference in New Issue
Block a user