Skip to content

Commit

Permalink
Delay reconnect attempts if the server returned an error (#47)
Browse files Browse the repository at this point in the history
This should fix high CPU usage issue when API key is invalid. Partial fixes #46.
  • Loading branch information
virusman authored and xor-gate committed Jun 4, 2018
1 parent e772656 commit b994571
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions syncthing/STStatusMonitor.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ - (void) longPoll {
self.lastSeenId = 0;
[NSThread sleepForTimeInterval:1.0];
}

NSInteger statusCode = ((NSHTTPURLResponse *)serverResponse).statusCode;
if (myError != nil || statusCode >= 400) {
// Retry after delay if the server returned an error
[NSThread sleepForTimeInterval:1.0];
}
}

if (self.enabled)
Expand Down

0 comments on commit b994571

Please sign in to comment.