aboutsummaryrefslogtreecommitdiffstats
path: root/tun_linux.go
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tun_linux.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/tun_linux.go b/tun_linux.go
index f5b24dc..629a5ec 100644
--- a/tun_linux.go
+++ b/tun_linux.go
@@ -357,9 +357,13 @@ func (tun *NativeTun) Events() chan TUNEvent {
func (tun *NativeTun) Close() error {
var err1 error
- close(tun.statusListenersShutdown)
- if tun.netlinkCancel != nil {
- err1 = tun.netlinkCancel.Cancel()
+ if tun.statusListenersShutdown != nil {
+ close(tun.statusListenersShutdown)
+ if tun.netlinkCancel != nil {
+ err1 = tun.netlinkCancel.Cancel()
+ }
+ } else if tun.events != nil {
+ close(tun.events)
}
err2 := tun.fd.Close()
err3 := tun.fdCancel.Cancel()