From 7ec54e00643284a9be4681269de11efba4a5d173 Mon Sep 17 00:00:00 2001 From: David Crawshaw Date: Wed, 11 Mar 2020 10:40:46 -0400 Subject: [PATCH] wgengine/magicsock: remove TODO The TODO above derphttp.NewClient suggests it does network I/O, but the derphttp client connects lazily and so creating one is very cheap. Signed-off-by: David Crawshaw --- wgengine/magicsock/magicsock.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wgengine/magicsock/magicsock.go b/wgengine/magicsock/magicsock.go index ce3903905..b67f0bd31 100644 --- a/wgengine/magicsock/magicsock.go +++ b/wgengine/magicsock/magicsock.go @@ -706,7 +706,8 @@ func (c *Conn) derpWriteChanOfAddr(addr *net.UDPAddr) chan<- derpWriteRequest { return nil } - // TODO(bradfitz): don't hold derpMu here. It's slow. Release first and use singleflight to dial+re-lock to add. + // Note that derphttp.NewClient does not dial the server + // so it is safe to do under the derpMu lock. dc, err := derphttp.NewClient(c.privateKey, "https://"+derpSrv.HostHTTPS+"/derp", c.logf) if err != nil { c.logf("derphttp.NewClient: port %d, host %q invalid? err: %v", addr.Port, derpSrv.HostHTTPS, err)