mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2026-11-30 01:16:53 +00:00
fix: easytier drain unused host packets to prevent data-plane stalls (#3400)
Consume raw host/TUN packet egress for each running instance so the bounded EasyTier packet sink cannot backpressure the data plane. Stop receiving when the instance closes or the adapter is canceled, and document packet ownership.
This commit is contained in:
1 parent
f1f640b12f
commit
9002a4fed3
1 file changed
+12
@@ -315,9 +315,21 @@ func (e *EasyTier) init() error {
|
||||
return err
|
||||
}
|
||||
log.Infoln("[EasyTier](%s) instance %s running", e.Name(), instance.ID())
|
||||
go e.drainHostPackets(instance)
|
||||
return nil
|
||||
}
|
||||
|
||||
// The outbound uses the core's netstack, not a host TUN device. Drain unused
|
||||
// raw IP packets so the bounded host packet queue cannot stall the data plane.
|
||||
// ReceivePacket unblocks when the instance closes or the adapter is canceled.
|
||||
func (e *EasyTier) drainHostPackets(instance *corehost.Instance) {
|
||||
for {
|
||||
if _, err := instance.ReceivePacket(e.ctx); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (e *EasyTier) currentInstance() (*corehost.Instance, error) {
|
||||
e.mu.Lock()
|
||||
defer e.mu.Unlock()
|
||||
|
||||
Reference in new issue
Block a user