Prevent remove ray

This commit is contained in:
风扇滑翔翼 2025-07-15 16:11:14 +00:00 committed by GitHub
parent 523e583299
commit 399ec65c8c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -44,6 +44,10 @@ func NewDispatcher(dispatcher routing.Dispatcher, callback ResponseCallback) *Di
func (v *Dispatcher) RemoveRay() {
v.Lock()
defer v.Unlock()
v.removeRay()
}
func (v *Dispatcher) removeRay() {
if v.conn != nil {
common.Interrupt(v.conn.link.Reader)
common.Close(v.conn.link.Writer)
@ -64,9 +68,11 @@ func (v *Dispatcher) getInboundRay(ctx context.Context, dest net.Destination) (*
ctx, cancel := context.WithCancel(ctx)
entry := &connEntry{}
removeRay := func() {
v.Lock()
defer v.Unlock()
if entry == v.conn {
cancel()
v.RemoveRay()
v.removeRay()
} else {
errors.LogError(ctx, "removeRay trying to remove a conn that not belongs to it, canceling.")
}