@@ -198,20 +198,21 @@ func (br *bodyReader) Read(p []byte) (int, error) {
198
198
}
199
199
}
200
200
201
- // millisecondsSinceOptional is like time.Since (tm).Milliseconds, but it returns a floating-point value.
202
- // If the input time is time.Time{}, it returns math.NaN()
203
- func millisecondsSinceOptional (tm time.Time ) float64 {
201
+ // millisecondsSinceOptional is like currentTime.Sub (tm).Milliseconds, but it returns a floating-point value.
202
+ // If tm is time.Time{}, it returns math.NaN()
203
+ func millisecondsSinceOptional (currentTime time. Time , tm time.Time ) float64 {
204
204
if tm == (time.Time {}) {
205
205
return math .NaN ()
206
206
}
207
- return float64 (time . Since (tm ).Nanoseconds ()) / 1_000_000.0
207
+ return float64 (currentTime . Sub (tm ).Nanoseconds ()) / 1_000_000.0
208
208
}
209
209
210
210
// errorIfNotReconnecting makes a heuristic decision whether we should reconnect after err at redactedURL; if so, it returns nil,
211
211
// otherwise it returns an appropriate error to return to the caller (possibly augmented with data about the heuristic)
212
212
func (br * bodyReader ) errorIfNotReconnecting (originalErr error , redactedURL string ) error {
213
- totalTime := millisecondsSinceOptional (br .firstConnectionTime )
214
- failureTime := millisecondsSinceOptional (br .lastSuccessTime )
213
+ currentTime := time .Now ()
214
+ totalTime := millisecondsSinceOptional (currentTime , br .firstConnectionTime )
215
+ failureTime := millisecondsSinceOptional (currentTime , br .lastSuccessTime )
215
216
logrus .Debugf ("Reading blob body from %s failed (%#v), decision inputs: lastRetryOffset %d, offset %d, %.3f ms since first connection, %.3f ms since last progress" ,
216
217
redactedURL , originalErr , br .lastRetryOffset , br .offset , totalTime , failureTime )
217
218
progress := br .offset - br .lastRetryOffset
0 commit comments