wireguard: Fix events chan leak

This commit is contained in:
世界
2024-08-26 14:01:32 +08:00
parent 45200ddefd
commit 2846ff6fac
3 changed files with 54 additions and 52 deletions

View File

@@ -230,17 +230,13 @@ func (w *StackDevice) Events() <-chan wgTun.Event {
}
func (w *StackDevice) Close() error {
select {
case <-w.done:
return os.ErrClosed
default:
}
close(w.done)
close(w.events)
w.stack.Close()
for _, endpoint := range w.stack.CleanupEndpoints() {
endpoint.Abort()
}
w.stack.Wait()
close(w.done)
return nil
}