mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-07-23 18:34:14 +00:00
Prevent remove ray
This commit is contained in:
parent
523e583299
commit
399ec65c8c
1 changed files with 7 additions and 1 deletions
|
@ -44,6 +44,10 @@ func NewDispatcher(dispatcher routing.Dispatcher, callback ResponseCallback) *Di
|
||||||
func (v *Dispatcher) RemoveRay() {
|
func (v *Dispatcher) RemoveRay() {
|
||||||
v.Lock()
|
v.Lock()
|
||||||
defer v.Unlock()
|
defer v.Unlock()
|
||||||
|
v.removeRay()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *Dispatcher) removeRay() {
|
||||||
if v.conn != nil {
|
if v.conn != nil {
|
||||||
common.Interrupt(v.conn.link.Reader)
|
common.Interrupt(v.conn.link.Reader)
|
||||||
common.Close(v.conn.link.Writer)
|
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)
|
ctx, cancel := context.WithCancel(ctx)
|
||||||
entry := &connEntry{}
|
entry := &connEntry{}
|
||||||
removeRay := func() {
|
removeRay := func() {
|
||||||
|
v.Lock()
|
||||||
|
defer v.Unlock()
|
||||||
if entry == v.conn {
|
if entry == v.conn {
|
||||||
cancel()
|
cancel()
|
||||||
v.RemoveRay()
|
v.removeRay()
|
||||||
} else {
|
} else {
|
||||||
errors.LogError(ctx, "removeRay trying to remove a conn that not belongs to it, canceling.")
|
errors.LogError(ctx, "removeRay trying to remove a conn that not belongs to it, canceling.")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue