Skip to content

Commit

Permalink
Merge a20e2c1 into 3cccacc
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgraehl committed Jul 26, 2023
2 parents 3cccacc + a20e2c1 commit 7029c91
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Source/santasyncservice/SNTSyncStage.m
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,12 @@ - (NSDictionary *)performRequest:(NSURLRequest *)request timeout:(NSTimeInterval
NSError *error;
NSData *data;

for (int attempt = 1; attempt < 6; ++attempt) {
if (attempt > 1) {
struct timespec ts = {.tv_sec = (attempt * 2)};
int maxAttempts = 5;
for (int attempt = 1; attempt <= maxAttempts; ++attempt) {
if (attempt >= 2) {
// Exponentially back off with larger and larger delays.
int exponentialBackoffMultiplier = 2; // E.g. 2^2 = 4, 2^3 = 8, 2^4 = 16...
struct timespec ts = {.tv_sec = pow(exponentialBackoffMultiplier, attempt)};
nanosleep(&ts, NULL);
}

Expand Down

0 comments on commit 7029c91

Please sign in to comment.