github.com/geph-official/geph2@v0.22.6-0.20210211030601-f527cb59b0df/libs/kcppp/session_helpers.go (about) 1 package kcppp 2 3 import ( 4 "log" 5 "time" 6 ) 7 8 func (sess *session) setTimer() { 9 sess.rtoTimer.actions <- rtAction{ 10 dline: time.Now().Add(time.Second * 2), 11 action: func() { 12 sess.lock.Lock() 13 defer sess.lock.Unlock() 14 if doLogging { 15 log.Println(sess.convID, "timer fired") 16 } 17 // send the last unacknowledged one 18 for _, seg := range sess.inFlight { 19 if !seg.acked { 20 if doLogging { 21 log.Println(sess.convID, 22 "RTO sending last unack", 23 seg.seg.Header.Seqno) 24 } 25 sess.sendCallback(seg.seg) 26 seg.retransTimes++ 27 go sess.setTimer() 28 break 29 } 30 } 31 }, 32 } 33 } 34 35 func diff32(later, earlier uint32) int32 { 36 return (int32)(later - earlier) 37 }