aboutsummaryrefslogtreecommitdiffstats
path: root/tun/tun_darwin.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-04-19 07:53:19 +0900
committerJason A. Donenfeld <Jason@zx2c4.com>2019-04-19 07:53:19 +0900
commitd0243933350ffdb45a3981b5015932daa603a83b (patch)
treee72ab7563c792fc42ca24ec596ff98af22c6dcec /tun/tun_darwin.go
parentmain: revise warnings (diff)
downloadwireguard-go-d0243933350ffdb45a3981b5015932daa603a83b.tar.xz
wireguard-go-d0243933350ffdb45a3981b5015932daa603a83b.zip
tun: darwin: write routeSocket variable in helper
Otherwise the race detector "complains".
Diffstat (limited to '')
-rw-r--r--tun/tun_darwin.go6
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)
}