1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-31 05:04:23 +03:00
This commit is contained in:
Vladimir Mihailenco
2019-06-14 16:00:03 +03:00
parent c0e70ad31d
commit 880e05d975
7 changed files with 15 additions and 22 deletions

View File

@ -95,7 +95,10 @@ func (cn *Conn) deadline(ctx context.Context, timeout time.Duration) time.Time {
if timeout == 0 {
return deadline
}
return minNonzeroTime(deadline, tm)
if deadline.Before(tm) {
return deadline
}
return tm
}
}
@ -105,13 +108,3 @@ func (cn *Conn) deadline(ctx context.Context, timeout time.Duration) time.Time {
return noDeadline
}
func minNonzeroTime(a, b time.Time) time.Time {
if a.IsZero() {
return b
}
if b.IsZero() || a.Before(b) {
return a
}
return b
}