mirror of
https://git.zx2c4.com/wireguard-go
synced 2025-10-10 19:10:08 +08:00
Fix race with closing event channel
There's still a tiny race on Linux, since the tun channel is written to from two places.
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user