Skip to content

v1.1.2 - dedupe race fix

Choose a tag to compare

@enesilhaydin enesilhaydin released this 21 May 11:57
· 13 commits to main since this release

Fixes duplicate FORWARD-hook accumulation that built up over reboots and link-UP events in v1.1.1.

Bug

post-fs-data retry, service.sh periodic sweep, and the ip-monitor event sweep all ran concurrently. Each did -C ... || -I without coordination. Racing -C checks could pass on the same missing rule, then both inserts would land. Net effect: duplicate -i <iface> -j lan_killswitch rules accumulated.

Fix

  • mkdir-based atomic mutex at /data/adb/lan-killswitch.lock wrapping every sweep. Stale-lock detection (mtime > 30s) prevents permanent deadlock if a holder dies.
  • ensure_hook() is now strictly idempotent: counts existing matches, deletes any extras, inserts exactly one if absent.
  • Identical logic in post-fs-data so it never races with service.sh.

Hook count converges to exactly 1 per interface per family regardless of how many sweeps fire in parallel.