Close events channel when no status listener

This commit is contained in:
Jason A. Donenfeld
2018-05-21 14:16:46 +02:00
parent 7472930d4e
commit 837a12c841
2 changed files with 10 additions and 3 deletions

View File

@@ -303,6 +303,9 @@ func (tun *NativeTun) Close() error {
// Surprisingly, on Darwin, simply closing a route socket is enough to unblock it.
// We don't even need to call shutdown, or use a rwcancel.
err3 = unix.Close(tun.routeSocket)
tun.routeSocket = -1
} else if tun.events != nil {
close(tun.events)
}
if err1 != nil {
return err1