Skip to content

Commit

Permalink
update time
Browse files Browse the repository at this point in the history
  • Loading branch information
xtaci committed Jan 14, 2017
1 parent 44fe2c2 commit 2375cf6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions kcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ func (kcp *KCP) parse_data(newseg *Segment) {

// Input when you received a low level packet (eg. UDP packet), call it
func (kcp *KCP) Input(data []byte, update_ack bool) int {
current := currentMs()
una := kcp.snd_una
if len(data) < IKCP_OVERHEAD {
return -1
Expand Down Expand Up @@ -531,8 +532,8 @@ func (kcp *KCP) Input(data []byte, update_ack bool) int {
kcp.shrink_buf()

if cmd == IKCP_CMD_ACK {
if update_ack && _itimediff(currentMs(), ts) >= 0 {
kcp.update_ack(_itimediff(currentMs(), ts))
if update_ack && _itimediff(current, ts) >= 0 {
kcp.update_ack(_itimediff(current, ts))
}
kcp.parse_ack(sn)
kcp.shrink_buf()
Expand Down Expand Up @@ -735,7 +736,7 @@ func (kcp *KCP) flush() {
// flush data segments
var lostSegs, fastRetransSegs, earlyRetransSegs uint64
for k := range kcp.snd_buf {
current := current
current := currentMs()
segment := &kcp.snd_buf[k]
needsend := false
if segment.xmit == 0 {
Expand Down Expand Up @@ -851,7 +852,7 @@ func (kcp *KCP) Update() {
kcp.ts_flush = current
}

slap = _itimediff(currentMs(), kcp.ts_flush)
slap = _itimediff(current, kcp.ts_flush)

if slap >= 10000 || slap < -10000 {
kcp.ts_flush = current
Expand Down

0 comments on commit 2375cf6

Please sign in to comment.