Skip to content

Commit

Permalink
Makes sure we stop the dispatch_source to prevent cycle/leak (#1161)
Browse files Browse the repository at this point in the history
* Makes sure we stop the dispatch_source to prevent cycle/leak

* reverts unnecessary change

* test on 6s only
  • Loading branch information
flovilmart authored Jul 20, 2017
1 parent 447287a commit 04fdc46
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Parse/Internal/PFEventuallyQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ extern NSTimeInterval const PFEventuallyQueueDefaultTimeoutRetryInterval;
- (void)start NS_REQUIRES_SUPER;
- (void)resume NS_REQUIRES_SUPER;
- (void)pause NS_REQUIRES_SUPER;

- (void)stop NS_REQUIRES_SUPER;
- (void)removeAllCommands NS_REQUIRES_SUPER;

@end
Expand Down
4 changes: 4 additions & 0 deletions Parse/Internal/PFEventuallyQueue.m
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ - (void)pause {
dispatch_suspend(_processingQueueSource);
}

- (void)stop {
dispatch_source_cancel(_processingQueueSource);
}

- (void)removeAllCommands {
dispatch_sync(_synchronizationQueue, ^{
[_taskCompletionSources removeAllObjects];
Expand Down
9 changes: 6 additions & 3 deletions Parse/Internal/ParseManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,15 @@ - (PFEventuallyQueue *)eventuallyQueue {
[PFPinningEventuallyQueue newDefaultPinningEventuallyQueueWithDataSource:self]
:
commandCache);

// We still need to clear out the old command cache even if we're using Pinning in case
// anything is left over when the user upgraded. Checking number of pending and then
// clearing should be enough.
if (self.offlineStoreLoaded && commandCache.commandCount > 0) {
[commandCache removeAllCommands];
if (self.offlineStoreLoaded) {
if (commandCache.commandCount > 0) {
[commandCache removeAllCommands];
}
// we won't need it after stop everything...
[commandCache stop];
}
}
#endif
Expand Down
3 changes: 1 addition & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,7 @@ namespace :test do

t.scheme = 'Parse-iOS'
t.sdk = 'iphonesimulator'
t.destinations = ["\"platform=iOS Simulator,OS=9.1,name=iPhone 4s\"",
"\"platform=iOS Simulator,OS=9.1,name=iPhone 6s\"",]
t.destinations = ["\"platform=iOS Simulator,OS=9.1,name=iPhone 6s\"",]
t.configuration = 'Debug'
t.additional_options = { "GCC_INSTRUMENT_PROGRAM_FLOW_ARCS" => "YES",
"GCC_GENERATE_TEST_COVERAGE_FILES" => "YES" }
Expand Down

0 comments on commit 04fdc46

Please sign in to comment.