mirror of
https://github.com/KusakabeShi/EtherGuard-VPN.git
synced 2025-08-09 07:31:23 +02: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