From: Jason A. Donenfeld Date: Thu, 18 Apr 2019 22:53:19 +0000 (+0900) Subject: tun: darwin: write routeSocket variable in helper X-Git-Tag: 0.0.20190517~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d0243933350ffdb45a3981b5015932daa603a83b;p=thirdparty%2Fwireguard-go.git tun: darwin: write routeSocket variable in helper Otherwise the race detector "complains". --- diff --git a/tun/tun_darwin.go b/tun/tun_darwin.go index 2077de3..2afe9de 100644 --- a/tun/tun_darwin.go +++ b/tun/tun_darwin.go @@ -47,7 +47,10 @@ func (tun *NativeTun) routineRouteListener(tunIfindex int) { statusMTU int ) - defer close(tun.events) + defer func() { + close(tun.events) + tun.routeSocket = -1 + }() data := make([]byte, os.Getpagesize()) for { @@ -292,7 +295,6 @@ func (tun *NativeTun) Close() error { if tun.routeSocket != -1 { unix.Shutdown(tun.routeSocket, unix.SHUT_RDWR) err2 = unix.Close(tun.routeSocket) - tun.routeSocket = -1 } else if tun.events != nil { close(tun.events) }