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

fix(session tracker): fix synchronization of de-duplication code #756

Merged
merged 2 commits into from
Jul 17, 2020
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
15 changes: 9 additions & 6 deletions Bugsnag/Delivery/BugsnagSessionTrackingApiClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,15 @@ - (void)deliverSessionsInStore:(BugsnagSessionFileStore *)store {
NSDictionary<NSString *, NSDictionary *> *filesWithIds = [store allFilesByName];

for (NSString *fileId in [filesWithIds allKeys]) {
// skip dupe requests
if ([self isActiveRequest:fileId]) {
continue;

// De-duplicate files as deletion of the file is asynchronous and so multiple calls
// to this method will result in multiple send requests
@synchronized (self.activeIds) {
if ([self.activeIds containsObject:fileId]) {
continue;
}
[self.activeIds addObject:fileId];
}
// add request
[self.activeIds addObject:fileId];

BugsnagSession *session = [[BugsnagSession alloc] initWithDictionary:filesWithIds[fileId]];

Expand All @@ -77,7 +80,7 @@ - (void)deliverSessionsInStore:(BugsnagSessionFileStore *)store {
headers:HTTPHeaders
onCompletion:^(NSUInteger sentCount, BOOL success, NSError *error) {
if (success && error == nil) {
bsg_log_info(@"Sent %lu sessions to Bugsnag", (unsigned long) sessionCount);
bsg_log_info(@"Sent session %@ to Bugsnag", session.id);
[store deleteFileWithId:fileId];
} else {
bsg_log_warn(@"Failed to send sessions to Bugsnag: %@", error);
tomlongridge marked this conversation as resolved.
Show resolved Hide resolved
tomlongridge marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog
=========

## TBD

### Bug fixes

* Synchronize access to sessions being delivered in de-duplication code
tomlongridge marked this conversation as resolved.
Show resolved Hide resolved

## 6.1.1 (2020-07-16)

### Bug fixes
Expand Down