Skip to content

Commit e4ddb1b

Browse files
authored
Fixes issue related to heap corruption (parse-community#1170)
* Fixes issue related to heap corruption - a block was capturing self in dealloc through _stopMonitoring - this removed the retain cycle at dealloc * Better handling of EventuallyQueue termination * Fixes issue for cocoapods * fixup! Fixes issue for cocoapods
1 parent 36ef251 commit e4ddb1b

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

Parse/Internal/PFEventuallyQueue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ extern NSTimeInterval const PFEventuallyQueueDefaultTimeoutRetryInterval;
6767
- (void)start NS_REQUIRES_SUPER;
6868
- (void)resume NS_REQUIRES_SUPER;
6969
- (void)pause NS_REQUIRES_SUPER;
70-
- (void)stop NS_REQUIRES_SUPER;
70+
- (void)terminate NS_REQUIRES_SUPER;
7171
- (void)removeAllCommands NS_REQUIRES_SUPER;
7272

7373
@end

Parse/Internal/PFEventuallyQueue.m

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,6 @@ - (instancetype)initWithDataSource:(id<PFCommandRunnerProvider>)dataSource
8080
return self;
8181
}
8282

83-
- (void)dealloc {
84-
[self _stopMonitoringNetworkReachability];
85-
}
86-
8783
///--------------------------------------
8884
#pragma mark - Enqueueing Commands
8985
///--------------------------------------
@@ -197,7 +193,8 @@ - (void)pause {
197193
dispatch_suspend(_processingQueueSource);
198194
}
199195

200-
- (void)stop {
196+
- (void)terminate {
197+
[self _stopMonitoringNetworkReachability];
201198
dispatch_source_cancel(_processingQueueSource);
202199
}
203200

@@ -383,7 +380,6 @@ - (void)_stopMonitoringNetworkReachability {
383380
[[PFReachability sharedParseReachability] removeListener:self];
384381

385382
self.monitorsReachability = NO;
386-
self.connected = YES;
387383
#endif
388384
}
389385

@@ -393,9 +389,11 @@ - (void)_stopMonitoringNetworkReachability {
393389

394390
/** Manually sets the network connection status. */
395391
- (void)setConnected:(BOOL)connected {
392+
@weakify(self);
396393
BFTaskCompletionSource *barrier = [BFTaskCompletionSource taskCompletionSource];
397394
dispatch_async(_processingQueue, ^{
398395
dispatch_sync(_synchronizationQueue, ^{
396+
@strongify(self);
399397
if (self.connected != connected) {
400398
_connected = connected;
401399
if (connected) {

Parse/Internal/PFReachability.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ - (void)addListener:(id<PFReachabilityListener>)listener {
130130
}
131131

132132
- (void)removeListener:(id<PFReachabilityListener>)listener {
133+
@weakify(listener);
133134
dispatch_barrier_sync(_synchronizationQueue, ^{
135+
@strongify(listener);
134136
[_listenersArray filterUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) {
135137
id weakObject = [evaluatedObject weakObject];
136138
return (weakObject == nil || weakObject == listener);

Parse/Internal/ParseManager.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ - (PFEventuallyQueue *)eventuallyQueue {
181181
if (commandCache.commandCount > 0) {
182182
[commandCache removeAllCommands];
183183
}
184-
// we won't need it after stop everything...
185-
[commandCache stop];
184+
// we won't need it after, terminate...
185+
[commandCache terminate];
186186
}
187187
}
188188
#endif

0 commit comments

Comments
 (0)