Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync: Improve logging when connection restored, avoid retries. #1408

Merged
merged 2 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Source/santasyncservice/SNTSyncManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ - (SNTSyncStatusType)preflightOnly:(BOOL)preflightOnly {
return [self eventUploadWithSyncState:syncState];
}

LOGE(@"Preflight failed, will try again once %@ is reachable",
SLOGE(@"Preflight failed, will try again once %@ is reachable",
[[SNTConfigurator configurator] syncBaseURL].absoluteString);
[self startReachability];
return SNTSyncStatusTypePreflightFailed;
Expand Down Expand Up @@ -386,6 +386,7 @@ - (SNTSyncState *)createSyncStateWithStatus:(SNTSyncStatusType *)status {
- (void)setReachable:(BOOL)reachable {
_reachable = reachable;
if (reachable) {
LOGD(@"Internet connection has been restored, triggering a new sync.");
[self stopReachability];
[self sync];
}
Expand Down
6 changes: 6 additions & 0 deletions Source/santasyncservice/SNTSyncStage.mm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#import "Source/santasyncservice/SNTSyncStage.h"

#include <Foundation/Foundation.h>
#import <MOLXPCConnection/MOLXPCConnection.h>

#import "Source/common/SNTCommonEnums.h"
Expand Down Expand Up @@ -176,6 +177,11 @@ - (NSData *)dataFromRequest:(NSURLRequest *)request
data = [self performRequest:request timeout:timeout response:&response error:&requestError];
if (response.statusCode == 200) break;

// If the original request failed because of a "No network" error, break out of the loop,
// subsequent retries are pointless and the entire sync will be retried once a connection
// is established.
if (requestError.code == NSURLErrorNotConnectedToInternet) break;

// If the original request failed because of an auth error, attempt to get a new XSRF token and
// try again. Unfortunately some servers cause NSURLSession to return 'client cert required' or
// 'could not parse response' when a 403 occurs and SSL cert auth is enabled.
Expand Down
Loading