[Issue #398] Adding state checks to AFURLConnectionOperation -pause to prevent likely memry issues when cancelling a non-existint connection

This commit is contained in:
Mattt Thompson 2012-07-23 16:20:11 -07:00
parent 9236e41850
commit 70787ce4cf

View file

@ -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];
self.state = AFHTTPOperationPausedState;
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.lock unlock];
}