Fix darwin batch loop not exit on EBADF

This commit is contained in:
世界 2026-03-05 20:32:32 +08:00
parent 90ea7a0b69
commit c81ce6d358
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
2 changed files with 5 additions and 2 deletions

View file

@ -3,6 +3,9 @@
package tun
import (
"errors"
"syscall"
"github.com/sagernet/gvisor/pkg/buffer"
"github.com/sagernet/gvisor/pkg/tcpip"
gHdr "github.com/sagernet/gvisor/pkg/tcpip/header"
@ -169,7 +172,7 @@ func (m *Mixed) batchLoopDarwin(darwinTUN DarwinTUN) {
for {
buffers, err := darwinTUN.BatchRead()
if err != nil {
if E.IsClosed(err) {
if E.IsClosed(err) || errors.Is(err, syscall.EBADF) {
return
}
m.logger.Error(E.Cause(err, "batch read packet"))