Fix system TUN read loop stopping on write errors

This commit is contained in:
世界
2026-09-25 19:28:45 +08:00
parent af6e64c3b6
commit 4537a1ac00
2 changed files with 6 additions and 12 deletions
+3 -6
View File
@@ -152,8 +152,7 @@ func (d *systemDevice) readLoop(tunInterface tun.Tun, mtu int) {
err = d.writeOutbound([]*buf.Buffer{packetBuffer})
packetBuffer.DecRef()
if err != nil {
d.options.Logger.Error(E.Cause(err, "write packet"))
return
d.options.Logger.Debug(E.Cause(err, "write packet"))
}
}
}
@@ -183,8 +182,7 @@ func (d *systemDevice) readLoopLinux(tunInterface tun.LinuxTUN, batchSize int, m
packetBuffers[i].DecRef()
}
if writeErr != nil {
d.options.Logger.Error(E.Cause(writeErr, "write packet batch"))
return
d.options.Logger.Debug(E.Cause(writeErr, "write packet batch"))
}
}
if readErr != nil {
@@ -211,8 +209,7 @@ func (d *systemDevice) readLoopDarwin(tunInterface tun.DarwinTUN) {
if len(outboundBuffers) > 0 {
writeErr := d.writeOutbound(outboundBuffers)
if writeErr != nil {
d.options.Logger.Error(E.Cause(writeErr, "write packet batch"))
return
d.options.Logger.Debug(E.Cause(writeErr, "write packet batch"))
}
}
if readErr != nil {
+3 -6
View File
@@ -155,8 +155,7 @@ func (d *systemDevice) readLoop(tunInterface tun.Tun, mtu int) {
err = d.writeOutbound([]*buf.Buffer{packetBuffer})
packetBuffer.DecRef()
if err != nil {
d.options.Logger.Error(E.Cause(err, "write packet"))
return
d.options.Logger.Debug(E.Cause(err, "write packet"))
}
}
}
@@ -193,8 +192,7 @@ func (d *systemDevice) readLoopLinux(tunInterface tun.LinuxTUN, batchSize int, m
packetBuffer.DecRef()
}
if writeErr != nil {
d.options.Logger.Error(E.Cause(writeErr, "write packet batch"))
return
d.options.Logger.Debug(E.Cause(writeErr, "write packet batch"))
}
}
if readErr != nil {
@@ -226,8 +224,7 @@ func (d *systemDevice) readLoopDarwin(tunInterface tun.DarwinTUN) {
if len(outboundBuffers) > 0 {
writeErr := d.writeOutbound(outboundBuffers)
if writeErr != nil {
d.options.Logger.Error(E.Cause(writeErr, "write packet batch"))
return
d.options.Logger.Debug(E.Cause(writeErr, "write packet batch"))
}
}
if readErr != nil {