diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-04-19 07:53:19 +0900 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-04-19 07:53:19 +0900 |
commit | d0243933350ffdb45a3981b5015932daa603a83b (patch) | |
tree | e72ab7563c792fc42ca24ec596ff98af22c6dcec /tun | |
parent | d9078fe772e8314f435c554d8f9b05ddfb0db9bf (diff) |
tun: darwin: write routeSocket variable in helper
Otherwise the race detector "complains".
Diffstat (limited to 'tun')
-rw-r--r-- | tun/tun_darwin.go | 6 |
1 files changed, 4 insertions, 2 deletions
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) } |