1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-09-30 07:46:41 -04:00

remove lastpayloadtime

This commit is contained in:
v2ray 2016-07-12 14:23:42 +02:00
parent b50671f041
commit f7d54d57c4
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

View File

@ -109,7 +109,6 @@ type Connection struct {
state State
stateBeginTime uint32
lastIncomingTime uint32
lastPayloadTime uint32
sendingUpdated bool
lastPingTime uint32
@ -399,12 +398,10 @@ func (this *Connection) Input(data []byte) int {
case *DataSegment:
this.HandleOption(seg.Opt)
this.receivingWorker.ProcessSegment(seg)
atomic.StoreUint32(&this.lastPayloadTime, current)
this.dataInputCond.Signal()
case *AckSegment:
this.HandleOption(seg.Opt)
this.sendingWorker.ProcessSegment(current, seg)
atomic.StoreUint32(&this.lastPayloadTime, current)
case *CmdOnlySegment:
this.HandleOption(seg.Opt)
if seg.Cmd == SegmentCommandTerminated {
@ -432,7 +429,7 @@ func (this *Connection) flush() {
if this.State() == StateTerminated {
return
}
if this.State() == StateActive && current-this.lastPayloadTime >= 30000 {
if this.State() == StateActive && current-atomic.LoadUint32(&this.lastIncomingTime) >= 30000 {
this.Close()
}
@ -443,13 +440,13 @@ func (this *Connection) flush() {
})
this.output.Flush()
if current-this.stateBeginTime > 8000 {
if current-atomic.LoadUint32(&this.stateBeginTime) > 8000 {
this.SetState(StateTerminated)
}
return
}
if this.State() == StateReadyToClose && current-this.stateBeginTime > 15000 {
if this.State() == StateReadyToClose && current-atomic.LoadUint32(&this.stateBeginTime) > 15000 {
this.SetState(StateTerminating)
}
@ -457,7 +454,7 @@ func (this *Connection) flush() {
this.receivingWorker.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.Conv = this.conv
seg.Cmd = SegmentCommandPing