correctly measure payload time

pull/215/head
v2ray 9 years ago
parent c5170a36f0
commit 6e615c5863
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

@ -67,6 +67,7 @@ type KCP struct {
state State state State
stateBeginTime uint32 stateBeginTime uint32
lastIncomingTime uint32 lastIncomingTime uint32
lastPayloadTime uint32
sendingUpdated bool sendingUpdated bool
receivingUpdated bool receivingUpdated bool
lastPingTime uint32 lastPingTime uint32
@ -325,6 +326,7 @@ func (kcp *KCP) Input(data []byte) int {
kcp.shrink_buf() kcp.shrink_buf()
kcp.acklist.Add(seg.Number, seg.Timestamp) kcp.acklist.Add(seg.Number, seg.Timestamp)
kcp.parse_data(seg) kcp.parse_data(seg)
kcp.lastPayloadTime = kcp.current
case *ACKSegment: case *ACKSegment:
kcp.HandleOption(seg.Opt) kcp.HandleOption(seg.Opt)
if kcp.rmt_wnd < seg.ReceivingWindow { if kcp.rmt_wnd < seg.ReceivingWindow {
@ -346,6 +348,7 @@ func (kcp *KCP) Input(data []byte) int {
} }
} }
kcp.shrink_buf() kcp.shrink_buf()
kcp.lastPayloadTime = kcp.current
case *CmdOnlySegment: case *CmdOnlySegment:
kcp.HandleOption(seg.Opt) kcp.HandleOption(seg.Opt)
if seg.Cmd == SegmentCommandTerminated { if seg.Cmd == SegmentCommandTerminated {
@ -377,7 +380,7 @@ func (kcp *KCP) flush() {
if kcp.state == StateTerminated { if kcp.state == StateTerminated {
return return
} }
if kcp.state == StateActive && _itimediff(kcp.current, kcp.lastIncomingTime) >= 30000 { if kcp.state == StateActive && _itimediff(kcp.current, kcp.lastPayloadTime) >= 30000 {
kcp.OnClose() kcp.OnClose()
} }

Loading…
Cancel
Save