Fix darwin batch read not exit on stop

This commit is contained in:
世界
2026-01-15 02:01:35 +08:00
parent 9d97d95a9c
commit 2f53768be2

View File

@@ -158,7 +158,10 @@ func (t *NativeTun) Close() error {
return t.tunFile.Close()
}
defer flushDNSCache()
return E.Errors(t.unsetRoutes(), t.tunFile.Close())
t.stopFd.Stop()
err := E.Errors(t.unsetRoutes(), t.tunFile.Close())
t.stopFd.Close()
return err
}
func (t *NativeTun) Read(p []byte) (n int, err error) {
@@ -356,6 +359,9 @@ func (t *NativeTun) BatchRead() ([]*buf.Buffer, error) {
t.buffers = t.buffers[:0]
return nil, errno
}
if n < 0 {
return nil, os.ErrClosed
}
if n < 1 {
return nil, nil
}