From f90ac11bd89eaee58181bea8e8dfff8d6f147ea5 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 1 Sep 2021 15:21:48 -0700 Subject: [PATCH] wgengine: remove unnecessary magicConnStarted channel. Having removed magicconn.Start, there's no need to synchronize startup of other things to it any more. Signed-off-by: David Anderson --- wgengine/userspace.go | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/wgengine/userspace.go b/wgengine/userspace.go index e4ff19245..7d41303ea 100644 --- a/wgengine/userspace.go +++ b/wgengine/userspace.go @@ -84,7 +84,6 @@ type userspaceEngine struct { wgLogger *wglog.Logger //a wireguard-go logging wrapper reqCh chan struct{} waitCh chan struct{} // chan is closed when first Close call completes; contrast with closing bool - magicConnStarted chan struct{} // chan is closed after magicConn.Start timeNow func() mono.Time tundev *tstun.Wrapper wgdev *device.Device @@ -264,15 +263,14 @@ func NewUserspaceEngine(logf logger.Logf, conf Config) (_ Engine, reterr error) closePool.add(tsTUNDev) e := &userspaceEngine{ - timeNow: mono.Now, - logf: logf, - reqCh: make(chan struct{}, 1), - waitCh: make(chan struct{}), - tundev: tsTUNDev, - router: conf.Router, - confListenPort: conf.ListenPort, - magicConnStarted: make(chan struct{}), - birdClient: conf.BIRDClient, + timeNow: mono.Now, + logf: logf, + reqCh: make(chan struct{}, 1), + waitCh: make(chan struct{}), + tundev: tsTUNDev, + router: conf.Router, + confListenPort: conf.ListenPort, + birdClient: conf.BIRDClient, } if e.birdClient != nil { @@ -402,8 +400,6 @@ func NewUserspaceEngine(logf logger.Logf, conf Config) (_ Engine, reterr error) } e.logf("Starting link monitor...") e.linkMon.Start() - e.logf("Starting magicsock...") - close(e.magicConnStarted) go e.pollResolver() @@ -1150,10 +1146,6 @@ func (e *userspaceEngine) LinkChange(_ bool) { } func (e *userspaceEngine) linkChange(changed bool, cur *interfaces.State) { - // Issue 2733: wait for e.magicConn to be started; there's two tiny - // windows at startup where this callback can be run before Start - <-e.magicConnStarted - up := cur.AnyInterfaceUp() if !up { e.logf("LinkChange: all links down; pausing: %v", cur)