mirror of
https://github.com/tailscale/tailscale.git
synced 2025-10-28 05:00:08 +00:00
feature,ipn/ipnlocal,wgengine: improve how eventbus shutdown is handled (#17156)
Instead of waiting for a designated subscription to close as a canary for the bus being stopped, use the bus Client's own signal for closure added in #17118. Updates #cleanup Change-Id: I384ea39f3f1f6a030a6282356f7b5bdcdf8d7102 Signed-off-by: M. J. Fromberger <fromberger@tailscale.com>
This commit is contained in:
@@ -640,15 +640,13 @@ func newConn(logf logger.Logf) *Conn {
|
||||
// [eventbus.Subscriber]'s and passes them to their related handler. Events are
|
||||
// always handled in the order they are received, i.e. the next event is not
|
||||
// read until the previous event's handler has returned. It returns when the
|
||||
// [portmapper.Mapping] subscriber is closed, which is interpreted to be the
|
||||
// same as the [eventbus.Client] closing ([eventbus.Subscribers] are either
|
||||
// all open or all closed).
|
||||
// [eventbus.Client] is closed.
|
||||
func (c *Conn) consumeEventbusTopics() {
|
||||
defer close(c.subsDoneCh)
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-c.pmSub.Done():
|
||||
case <-c.eventClient.Done():
|
||||
return
|
||||
case <-c.pmSub.Events():
|
||||
c.onPortMapChanged()
|
||||
|
||||
@@ -158,13 +158,11 @@ func newUserspaceRouterAdvanced(logf logger.Logf, tunname string, netMon *netmon
|
||||
// [eventbus.Subscriber]'s and passes them to their related handler. Events are
|
||||
// always handled in the order they are received, i.e. the next event is not
|
||||
// read until the previous event's handler has returned. It returns when the
|
||||
// [portmapper.Mapping] subscriber is closed, which is interpreted to be the
|
||||
// same as the [eventbus.Client] closing ([eventbus.Subscribers] are either
|
||||
// all open or all closed).
|
||||
// [eventbus.Client] is closed.
|
||||
func (r *linuxRouter) consumeEventbusTopics() {
|
||||
for {
|
||||
select {
|
||||
case <-r.ruleDeletedSub.Done():
|
||||
case <-r.eventClient.Done():
|
||||
return
|
||||
case rulesDeleted := <-r.ruleDeletedSub.Events():
|
||||
r.onIPRuleDeleted(rulesDeleted.Table, rulesDeleted.Priority)
|
||||
|
||||
Reference in New Issue
Block a user