Skip to content

Commit

Permalink
Fix retain cycle causing leak for backgroundPolicy RKRequestBackgroun…
Browse files Browse the repository at this point in the history
…dPolicyContinue. closes RestKit#548
  • Loading branch information
blakewatters committed Mar 12, 2012
1 parent 995c309 commit 749c6e3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Code/Network/RKRequest.m
Expand Up @@ -502,14 +502,16 @@ - (void)sendAsynchronously {
RKLogInfo(@"Beginning background task to perform processing...");

// Fork a background task for continueing a long-running request
__block RKRequest* weakSelf = self;
__block id<RKRequestDelegate> weakDelegate = _delegate;
_backgroundTaskIdentifier = [app beginBackgroundTaskWithExpirationHandler:^{
RKLogInfo(@"Background request time expired, canceling request.");

[self cancelAndInformDelegate:NO];
[self cleanupBackgroundTask];
[weakSelf cancelAndInformDelegate:NO];
[weakSelf cleanupBackgroundTask];

if ([_delegate respondsToSelector:@selector(requestDidTimeout:)]) {
[_delegate requestDidTimeout:self];
if ([weakDelegate respondsToSelector:@selector(requestDidTimeout:)]) {
[weakDelegate requestDidTimeout:weakSelf];
}
}];

Expand Down

0 comments on commit 749c6e3

Please sign in to comment.