mirror of
https://github.com/safing/portmaster.git
synced 2026-12-04 01:16:28 +00:00
458e708f13
IsMyIP and GetLocalNetwork held myNetworksLock while refreshMyNetworks called the OS, and that call sometimes takes seconds. Every waiting caller then made its own slow call once it got the lock, so the queue of goroutines only grew and DNS stayed blocked. The networks are now an atomic snapshot, read without a lock, and the refresh runs through singleflight: callers that arrive during a refresh share its result. The throttle counts from the end of the call, so slow calls do not run back to back, and the changed flag is reset before the call, so a change during it is not lost. Callers that arrive during a refresh after a network change wait for the new networks.