From d0243933350ffdb45a3981b5015932daa603a83b Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Fri, 19 Apr 2019 07:53:19 +0900 Subject: tun: darwin: write routeSocket variable in helper Otherwise the race detector "complains". --- tun/tun_darwin.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tun') 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) } -- cgit v1.2.3-59-g8ed1b