From 4cbb212319e7c68c8ed1df13090d4f6ba1060212 Mon Sep 17 00:00:00 2001 From: banaag Date: Tue, 19 Nov 2019 09:06:13 -0800 Subject: [PATCH] Fixed bug with wait time refactor. Tested manually, unit tests to follow in a follow-up PR. --- packager/certcache/certcache.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packager/certcache/certcache.go b/packager/certcache/certcache.go index a9d073fba..8e1d3e217 100644 --- a/packager/certcache/certcache.go +++ b/packager/certcache/certcache.go @@ -375,13 +375,14 @@ func (this *CertCache) readOCSP(allowRetries bool) ([]byte, time.Time, error) { for numTries := 0; numTries < maxTries; { ocsp, ocspUpdateAfter, err = this.readOCSPHelper(numTries, numTries >= maxTries - 1) if err != nil { - if numTries >= maxTries - 1 { - return nil, ocspUpdateAfter, err - } else { - numTries++ - waitTimeInMinutes = waitForSpecifiedTime(waitTimeInMinutes, numTries) - continue - } + return nil, ocspUpdateAfter, err + } + if !this.shouldUpdateOCSP(ocsp) { + break; + } + // Wait only if are not on our last try. + if numTries < maxTries - 1 { + waitTimeInMinutes = waitForSpecifiedTime(waitTimeInMinutes, numTries) } numTries++ }