mirror of
https://github.com/tailscale/tailscale.git
synced 2026-10-09 03:42:01 -04:00
Previously, ipconfig /flushdns and ipconfig /registerdns were called from multiple sites without coordination: the DNS manager's SetDNS (in a fire-and-forget goroutine), the router's winRouter.Set (synchronously on every route change), the link change handler, and session unlock. These could fire concurrently or in rapid succession, spawning multiple ipconfig processes and putting excessive pressure on the Dnscache service. In this PR, we introduce a new util/coalescedop.CoalescedOp type that provides "one in-flight, at most one pending" semantics: Do() is non-blocking, at most one execution runs at a time, and concurrent/rapid successive requests coalesce into a single follow-up execution. We then use CoalescedOp for both ipconfig /flushdns and ipconfig /registerdns, replacing the fire-and-forget goroutine in windowsManager.SetDNS and in the session unlock handler in tailscaled. We also remove the redundant dns.Flush() call from winRouter.Set, since every meaningful router.Set is followed by dns.Set in Reconfig, which already flushes. Updates #21001 Signed-off-by: Nick Khyl <nickk@tailscale.com>