Skip to content

Commit

Permalink
Extend the retry time to longer than refreshBuffer
Browse files Browse the repository at this point in the history
Fix an issue that reconnection does not happen if initial session binding fails.
If initial session binding fails�, retry time will be offset by `refreshBuffer`. Retry will not be registered in the timer.
Extend the retry time to longer than `refreshBuffer`.
  • Loading branch information
kishikawakatsumi committed Jul 19, 2017
1 parent 3396054 commit f7d0a74
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Realm/RLMSyncSessionRefreshHandle.mm
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ void unregisterRefreshHandle(const std::weak_ptr<SyncUser>& user, const std::str

}

static const NSTimeInterval RefreshBuffer = 10;

@interface RLMSyncSessionRefreshHandle () {
std::weak_ptr<SyncUser> _user;
std::string _path;
Expand Down Expand Up @@ -91,8 +93,7 @@ - (void)invalidate {
}

+ (NSDate *)fireDateForTokenExpirationDate:(NSDate *)date nowDate:(NSDate *)nowDate {
static const NSTimeInterval refreshBuffer = 10;
NSDate *fireDate = [date dateByAddingTimeInterval:-refreshBuffer];
NSDate *fireDate = [date dateByAddingTimeInterval:-RefreshBuffer];
// Only fire times in the future are valid.
return ([fireDate compare:nowDate] == NSOrderedDescending ? fireDate : nil);
}
Expand Down Expand Up @@ -190,7 +191,7 @@ - (BOOL)_handleFailedRequest:(NSError *)error {
case NSURLErrorDNSLookupFailed:
case NSURLErrorCannotFindHost:
// FIXME: 10 seconds is an arbitrarily chosen value, consider rationalizing it.
nextTryDate = [NSDate dateWithTimeIntervalSinceNow:10];
nextTryDate = [NSDate dateWithTimeIntervalSinceNow:RefreshBuffer + 10];
break;
default:
break;
Expand Down

0 comments on commit f7d0a74

Please sign in to comment.