mirror of https://github.com/v2ray/v2ray-core
remove lastpayloadtime
parent
b50671f041
commit
f7d54d57c4
|
@ -109,7 +109,6 @@ type Connection struct {
|
||||||
state State
|
state State
|
||||||
stateBeginTime uint32
|
stateBeginTime uint32
|
||||||
lastIncomingTime uint32
|
lastIncomingTime uint32
|
||||||
lastPayloadTime uint32
|
|
||||||
sendingUpdated bool
|
sendingUpdated bool
|
||||||
lastPingTime uint32
|
lastPingTime uint32
|
||||||
|
|
||||||
|
@ -399,12 +398,10 @@ func (this *Connection) Input(data []byte) int {
|
||||||
case *DataSegment:
|
case *DataSegment:
|
||||||
this.HandleOption(seg.Opt)
|
this.HandleOption(seg.Opt)
|
||||||
this.receivingWorker.ProcessSegment(seg)
|
this.receivingWorker.ProcessSegment(seg)
|
||||||
atomic.StoreUint32(&this.lastPayloadTime, current)
|
|
||||||
this.dataInputCond.Signal()
|
this.dataInputCond.Signal()
|
||||||
case *AckSegment:
|
case *AckSegment:
|
||||||
this.HandleOption(seg.Opt)
|
this.HandleOption(seg.Opt)
|
||||||
this.sendingWorker.ProcessSegment(current, seg)
|
this.sendingWorker.ProcessSegment(current, seg)
|
||||||
atomic.StoreUint32(&this.lastPayloadTime, current)
|
|
||||||
case *CmdOnlySegment:
|
case *CmdOnlySegment:
|
||||||
this.HandleOption(seg.Opt)
|
this.HandleOption(seg.Opt)
|
||||||
if seg.Cmd == SegmentCommandTerminated {
|
if seg.Cmd == SegmentCommandTerminated {
|
||||||
|
@ -432,7 +429,7 @@ func (this *Connection) flush() {
|
||||||
if this.State() == StateTerminated {
|
if this.State() == StateTerminated {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if this.State() == StateActive && current-this.lastPayloadTime >= 30000 {
|
if this.State() == StateActive && current-atomic.LoadUint32(&this.lastIncomingTime) >= 30000 {
|
||||||
this.Close()
|
this.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,13 +440,13 @@ func (this *Connection) flush() {
|
||||||
})
|
})
|
||||||
this.output.Flush()
|
this.output.Flush()
|
||||||
|
|
||||||
if current-this.stateBeginTime > 8000 {
|
if current-atomic.LoadUint32(&this.stateBeginTime) > 8000 {
|
||||||
this.SetState(StateTerminated)
|
this.SetState(StateTerminated)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if this.State() == StateReadyToClose && current-this.stateBeginTime > 15000 {
|
if this.State() == StateReadyToClose && current-atomic.LoadUint32(&this.stateBeginTime) > 15000 {
|
||||||
this.SetState(StateTerminating)
|
this.SetState(StateTerminating)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -457,7 +454,7 @@ func (this *Connection) flush() {
|
||||||
this.receivingWorker.Flush(current)
|
this.receivingWorker.Flush(current)
|
||||||
this.sendingWorker.Flush(current)
|
this.sendingWorker.Flush(current)
|
||||||
|
|
||||||
if this.sendingWorker.PingNecessary() || this.receivingWorker.PingNecessary() || current-this.lastPingTime >= 5000 {
|
if this.sendingWorker.PingNecessary() || this.receivingWorker.PingNecessary() || current-atomic.LoadUint32(&this.lastPingTime) >= 5000 {
|
||||||
seg := NewCmdOnlySegment()
|
seg := NewCmdOnlySegment()
|
||||||
seg.Conv = this.conv
|
seg.Conv = this.conv
|
||||||
seg.Cmd = SegmentCommandPing
|
seg.Cmd = SegmentCommandPing
|
||||||
|
|
Loading…
Reference in New Issue