func()

in connection.go [587:607]


func (w *gettyWSConn) updateWriteDeadline() error {
	var (
		err         error
		currentTime time.Time
	)

	if w.wTimeout.Load() > 0 {
		// Optimization: update write deadline only if more than 25%
		// of the last write deadline exceeded.
		// See https://github.com/golang/go/issues/15133 for details.
		currentTime = time.Now()
		if currentTime.Sub(w.wLastDeadline.Load()) > w.wTimeout.Load()>>2 {
			if err = w.conn.SetWriteDeadline(currentTime.Add(w.wTimeout.Load())); err != nil {
				return perrors.WithStack(err)
			}
			w.wLastDeadline.Store(currentTime)
		}
	}

	return nil
}