[Issue #398] Adding state checks to AFURLConnectionOperation -pause to prevent likely memry issues when cancelling a non-existint connection
This commit is contained in:
parent
9236e41850
commit
70787ce4cf
1 changed files with 8 additions and 4 deletions
|
|
@ -355,15 +355,19 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat
|
|||
}
|
||||
|
||||
- (void)pause {
|
||||
if ([self isPaused]) {
|
||||
if ([self isPaused] || [self isFinished]) {
|
||||
return;
|
||||
}
|
||||
|
||||
[self.lock lock];
|
||||
|
||||
if ([self isExecuting]) {
|
||||
[self.connection performSelector:@selector(cancel) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidFinishNotification object:self];
|
||||
}
|
||||
|
||||
self.state = AFHTTPOperationPausedState;
|
||||
|
||||
[self.connection performSelector:@selector(cancel) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidFinishNotification object:self];
|
||||
[self.lock unlock];
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue