mirror of
https://git.zx2c4.com/wireguard-go
synced 2025-10-08 18:10:19 +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:
@@ -89,7 +89,10 @@ func createNetlinkSocket() (int, error) {
|
||||
}
|
||||
|
||||
func (tun *NativeTun) RoutineNetlinkListener() {
|
||||
defer unix.Close(tun.netlinkSock)
|
||||
defer func() {
|
||||
unix.Close(tun.netlinkSock)
|
||||
close(tun.events)
|
||||
}()
|
||||
|
||||
for msg := make([]byte, 1<<16); ; {
|
||||
|
||||
@@ -357,7 +360,6 @@ func (tun *NativeTun) Close() error {
|
||||
}
|
||||
err2 := tun.fd.Close()
|
||||
err3 := tun.fdCancel.Cancel()
|
||||
close(tun.events)
|
||||
|
||||
if err1 != nil {
|
||||
return err1
|
||||
|
Reference in New Issue
Block a user