Call shutdown on route socket on freebsd

This commit is contained in:
Jason A. Donenfeld 2018-05-22 01:26:47 +02:00
parent bc05eb1c3c
commit b8c9e13c6e

View File

@ -441,8 +441,7 @@ func (tun *NativeTun) Close() error {
err2 := tun.fd.Close() err2 := tun.fd.Close()
err3 := tunDestroy(tun.name) err3 := tunDestroy(tun.name)
if tun.routeSocket != -1 { if tun.routeSocket != -1 {
// Surprisingly, on FreeBSD, simply closing a route socket is enough to unblock it. unix.Shutdown(tun.routeSocket, unix.SHUT_RDWR)
// We don't even need to call shutdown, or use a rwcancel. TODO: CONFIRM THIS CLAIM. IT WAS TRUE ON DARWIN BUT...
err4 = unix.Close(tun.routeSocket) err4 = unix.Close(tun.routeSocket)
tun.routeSocket = -1 tun.routeSocket = -1
} else if tun.events != nil { } else if tun.events != nil {