wait for goroutines to finish and for tun to actually be closed

This commit is contained in:
JackDoan
2026-04-16 13:19:25 -05:00
parent 183c1e3cfd
commit 6b2e6d9f55
6 changed files with 57 additions and 16 deletions

View File

@@ -831,18 +831,18 @@ func (t *tun) Close() error {
}
err := t.readers[i].Close()
if err != nil {
t.l.WithField("reader", i).WithError(err).Error("Error closing tun reader")
t.l.WithField("reader", i).WithError(err).Error("error closing tun reader")
} else {
t.l.WithField("reader", i).Info("Closed tun reader")
t.l.WithField("reader", i).Info("closed tun reader")
}
}
//this is t.readers[0] too
err := t.tunFile.Close()
if err != nil {
t.l.WithField("reader", 0).WithError(err).Error("Error closing tun reader")
t.l.WithField("reader", 0).WithError(err).Error("error closing tun reader")
} else {
t.l.WithField("reader", 0).Info("Closed tun reader")
t.l.WithField("reader", 0).Info("closed tun reader")
}
return err
}