mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-03 02:21:58 +00:00
wgengine/monitor: skip some macOS route updates, fix debounce regression
Debound was broken way back in 5c1e443d34 and we never noticed.
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
be779b3587
commit
471f0c470a
@@ -143,17 +143,24 @@ func (m *Mon) Close() error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *Mon) stopped() bool {
|
||||
select {
|
||||
case <-m.stop:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// pump continuously retrieves messages from the connection, notifying
|
||||
// the change channel of changes, and stopping when a stop is issued.
|
||||
func (m *Mon) pump() {
|
||||
defer m.goroutines.Done()
|
||||
for {
|
||||
for !m.stopped() {
|
||||
msg, err := m.om.Receive()
|
||||
if err != nil {
|
||||
select {
|
||||
case <-m.stop:
|
||||
if m.stopped() {
|
||||
return
|
||||
default:
|
||||
}
|
||||
// Keep retrying while we're not closed.
|
||||
m.logf("error from link monitor: %v", err)
|
||||
@@ -165,8 +172,10 @@ func (m *Mon) pump() {
|
||||
}
|
||||
select {
|
||||
case m.change <- struct{}{}:
|
||||
case <-m.stop:
|
||||
return
|
||||
default:
|
||||
// Another change signal is already
|
||||
// buffered. Debounce will wake up soon
|
||||
// enough.
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -199,7 +208,7 @@ func (m *Mon) debounce() {
|
||||
select {
|
||||
case <-m.stop:
|
||||
return
|
||||
case <-time.After(100 * time.Millisecond):
|
||||
case <-time.After(250 * time.Millisecond):
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user