mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-22 01:57:12 -05:00
completely remove itimediff
This commit is contained in:
parent
16d1b42f59
commit
344e48e1bb
@ -9,10 +9,6 @@ import (
|
||||
"github.com/v2ray/v2ray-core/common/log"
|
||||
)
|
||||
|
||||
func _itimediff(later, earlier uint32) int32 {
|
||||
return (int32)(later - earlier)
|
||||
}
|
||||
|
||||
type State int
|
||||
|
||||
const (
|
||||
@ -178,7 +174,7 @@ func (kcp *KCP) flush() {
|
||||
if kcp.state == StateTerminated {
|
||||
return
|
||||
}
|
||||
if kcp.state == StateActive && _itimediff(kcp.current, kcp.lastPayloadTime) >= 30000 {
|
||||
if kcp.state == StateActive && kcp.current-kcp.lastPayloadTime >= 30000 {
|
||||
kcp.OnClose()
|
||||
}
|
||||
|
||||
@ -189,13 +185,13 @@ func (kcp *KCP) flush() {
|
||||
})
|
||||
kcp.output.Flush()
|
||||
|
||||
if _itimediff(kcp.current, kcp.stateBeginTime) > 8000 {
|
||||
if kcp.current-kcp.stateBeginTime > 8000 {
|
||||
kcp.SetState(StateTerminated)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if kcp.state == StateReadyToClose && _itimediff(kcp.current, kcp.stateBeginTime) > 15000 {
|
||||
if kcp.state == StateReadyToClose && kcp.current-kcp.stateBeginTime > 15000 {
|
||||
kcp.SetState(StateTerminating)
|
||||
}
|
||||
|
||||
@ -203,7 +199,7 @@ func (kcp *KCP) flush() {
|
||||
kcp.receivingWorker.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.Conv = kcp.conv
|
||||
seg.Cmd = SegmentCommandPing
|
||||
|
@ -108,7 +108,7 @@ func (this *SendingWindow) HandleFastAck(number uint32) {
|
||||
|
||||
for i := this.start; ; i = this.next[i] {
|
||||
seg := this.data[i]
|
||||
if _itimediff(number, seg.Number) < 0 {
|
||||
if number-seg.Number > 0x7FFFFFFF {
|
||||
break
|
||||
}
|
||||
if number != seg.Number {
|
||||
@ -136,7 +136,7 @@ func (this *SendingWindow) Flush(current uint32, resend uint32, rto uint32, maxI
|
||||
segment.transmit++
|
||||
segment.timeout = current + rto
|
||||
this.totalInFlightSize++
|
||||
} else if _itimediff(current, segment.timeout) >= 0 {
|
||||
} else if current-segment.timeout < 0x7FFFFFFF {
|
||||
needsend = true
|
||||
segment.transmit++
|
||||
segment.timeout = current + rto
|
||||
|
Loading…
Reference in New Issue
Block a user