aboutsummaryrefslogtreecommitdiffstats
path: root/tun_darwin.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-05-20 06:38:39 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-05-20 06:38:39 +0200
commit18f43705ecbc8751bcf5ed05cd65cf93c36798b0 (patch)
tree2d19a90e474449a177e392caeb77388d4f76dbde /tun_darwin.go
parentStyle (diff)
downloadwireguard-go-18f43705ecbc8751bcf5ed05cd65cf93c36798b0.tar.xz
wireguard-go-18f43705ecbc8751bcf5ed05cd65cf93c36798b0.zip
Fix race with closing event channel
There's still a tiny race on Linux, since the tun channel is written to from two places.
Diffstat (limited to 'tun_darwin.go')
-rw-r--r--tun_darwin.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/tun_darwin.go b/tun_darwin.go
index 23c0b54..d2cdcd5 100644
--- a/tun_darwin.go
+++ b/tun_darwin.go
@@ -53,6 +53,8 @@ func (tun *NativeTun) RoutineRouteListener(tunIfindex int) {
statusMTU int
)
+ defer close(tun.events)
+
data := make([]byte, os.Getpagesize())
for {
n, err := unix.Read(tun.routeSocket, data)
@@ -302,7 +304,6 @@ func (tun *NativeTun) Close() error {
// We don't even need to call shutdown, or use a rwcancel.
err3 = unix.Close(tun.routeSocket)
}
- close(tun.events)
if err1 != nil {
return err1
}