1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 18:17:52 -05:00

completely remove itimediff

This commit is contained in:
v2ray 2016-07-05 21:47:35 +02:00
parent 16d1b42f59
commit 344e48e1bb
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
2 changed files with 6 additions and 10 deletions

View File

@ -9,10 +9,6 @@ import (
"github.com/v2ray/v2ray-core/common/log" "github.com/v2ray/v2ray-core/common/log"
) )
func _itimediff(later, earlier uint32) int32 {
return (int32)(later - earlier)
}
type State int type State int
const ( const (
@ -178,7 +174,7 @@ func (kcp *KCP) flush() {
if kcp.state == StateTerminated { if kcp.state == StateTerminated {
return return
} }
if kcp.state == StateActive && _itimediff(kcp.current, kcp.lastPayloadTime) >= 30000 { if kcp.state == StateActive && kcp.current-kcp.lastPayloadTime >= 30000 {
kcp.OnClose() kcp.OnClose()
} }
@ -189,13 +185,13 @@ func (kcp *KCP) flush() {
}) })
kcp.output.Flush() kcp.output.Flush()
if _itimediff(kcp.current, kcp.stateBeginTime) > 8000 { if kcp.current-kcp.stateBeginTime > 8000 {
kcp.SetState(StateTerminated) kcp.SetState(StateTerminated)
} }
return return
} }
if kcp.state == StateReadyToClose && _itimediff(kcp.current, kcp.stateBeginTime) > 15000 { if kcp.state == StateReadyToClose && kcp.current-kcp.stateBeginTime > 15000 {
kcp.SetState(StateTerminating) kcp.SetState(StateTerminating)
} }
@ -203,7 +199,7 @@ func (kcp *KCP) flush() {
kcp.receivingWorker.Flush() kcp.receivingWorker.Flush()
kcp.sendingWorker.Flush() kcp.sendingWorker.Flush()
if kcp.sendingWorker.PingNecessary() || kcp.receivingWorker.PingNecessary() || _itimediff(kcp.current, kcp.lastPingTime) >= 5000 { if kcp.sendingWorker.PingNecessary() || kcp.receivingWorker.PingNecessary() || kcp.current-kcp.lastPingTime >= 5000 {
seg := NewCmdOnlySegment() seg := NewCmdOnlySegment()
seg.Conv = kcp.conv seg.Conv = kcp.conv
seg.Cmd = SegmentCommandPing seg.Cmd = SegmentCommandPing

View File

@ -108,7 +108,7 @@ func (this *SendingWindow) HandleFastAck(number uint32) {
for i := this.start; ; i = this.next[i] { for i := this.start; ; i = this.next[i] {
seg := this.data[i] seg := this.data[i]
if _itimediff(number, seg.Number) < 0 { if number-seg.Number > 0x7FFFFFFF {
break break
} }
if number != seg.Number { if number != seg.Number {
@ -136,7 +136,7 @@ func (this *SendingWindow) Flush(current uint32, resend uint32, rto uint32, maxI
segment.transmit++ segment.transmit++
segment.timeout = current + rto segment.timeout = current + rto
this.totalInFlightSize++ this.totalInFlightSize++
} else if _itimediff(current, segment.timeout) >= 0 { } else if current-segment.timeout < 0x7FFFFFFF {
needsend = true needsend = true
segment.transmit++ segment.transmit++
segment.timeout = current + rto segment.timeout = current + rto