Only sleep if there is work to do

This commit is contained in:
peterbakker
2020-03-19 20:01:45 +01:00
parent 354f9f7e7e
commit fae8ff885c

View File

@@ -296,7 +296,9 @@ class Client
$this->signPayloadKid(null, $challenge->getAuthorizationURL()) $this->signPayloadKid(null, $challenge->getAuthorizationURL())
); );
$data = json_decode((string)$response->getBody(), true); $data = json_decode((string)$response->getBody(), true);
sleep(ceil(15 / $maxAttempts)); if ($maxAttempts > 1) {
sleep(ceil(15 / $maxAttempts));
}
$maxAttempts--; $maxAttempts--;
} while ($maxAttempts > 0 && $data['status'] != 'valid'); } while ($maxAttempts > 0 && $data['status'] != 'valid');
@@ -441,7 +443,9 @@ class Client
} }
} }
} }
sleep(ceil(45 / $maxAttempts)); if ($maxAttempts > 1) {
sleep(ceil(45 / $maxAttempts));
}
$maxAttempts--; $maxAttempts--;
} while ($maxAttempts > 0); } while ($maxAttempts > 0);