Ejemplo n.º 1
0
// first is true if this is the first time the send is acked. latency is
// calculated for the first ack.
func (s *send) Ack() (latency time.Duration, first bool) {
	first = !s.acked
	if first {
		latency = missinggo.MonotonicSince(s.started)
	}
	s.acked = true
	cond.Broadcast()
	if s.resendTimer != nil {
		s.resendTimer.Stop()
		s.resendTimer = nil
	}
	return
}
Ejemplo n.º 2
0
func (s *send) timeoutResend() {
	mu.Lock()
	defer mu.Unlock()
	if missinggo.MonotonicSince(s.started) >= writeTimeout {
		s.timedOut()
		return
	}
	if s.acked || s.conn.destroyed.Get() {
		return
	}
	rt := s.conn.resendTimeout()
	go s.resend()
	s.numResends++
	s.resendTimer.Reset(rt * time.Duration(s.numResends))
}