You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tailscale/net/netmon
Nick Khyl c9836b454d net/netmon: fix goroutine leak in winMon if the monitor is never started
When the portable Monitor creates a winMon via newOSMon, we register
address and route change callbacks with Windows. Once a callback is hit,
it starts a goroutine that attempts to send the event into messagec and returns.
The newly started goroutine then blocks until it can send to the channel.
However, if the monitor is never started and winMon.Receive is never called,
the goroutines remain indefinitely blocked, leading to goroutine leaks and
significant memory consumption in the tailscaled service process on Windows.
Unlike the tailscaled subprocess, the service process creates but never starts
a Monitor.

This PR adds a check within the callbacks to confirm the monitor's active status,
and exits immediately if the monitor hasn't started.

Updates #9864

Signed-off-by: Nick Khyl <nickk@tailscale.com>
2 years ago
..
netmon.go net/netmon: fix goroutine leak in winMon if the monitor is never started 2 years ago
netmon_darwin.go all: move network monitoring from wgengine/monitor to net/netmon 3 years ago
netmon_darwin_test.go all: move network monitoring from wgengine/monitor to net/netmon 3 years ago
netmon_freebsd.go all: move network monitoring from wgengine/monitor to net/netmon 3 years ago
netmon_linux.go all: adjust case of "IPv4" and "IPv6" 2 years ago
netmon_linux_test.go all: move network monitoring from wgengine/monitor to net/netmon 3 years ago
netmon_polling.go all: move network monitoring from wgengine/monitor to net/netmon 3 years ago
netmon_test.go net/{interfaces,netmon}: remove "interesting", EqualFiltered API 2 years ago
netmon_windows.go net/netmon: fix goroutine leak in winMon if the monitor is never started 2 years ago
polling.go net/netmon: factor out debounce loop, simplify polling impl 2 years ago