Showing
2 changed files
with
14 additions
and
12 deletions
@@ -245,9 +245,6 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount; | @@ -245,9 +245,6 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount; | ||
245 | // Number of seconds to wait before timing out - default is 10 | 245 | // Number of seconds to wait before timing out - default is 10 |
246 | NSTimeInterval timeOutSeconds; | 246 | NSTimeInterval timeOutSeconds; |
247 | 247 | ||
248 | - // Autorelease pool for the main loop, since it's highly likely that this operation will run in a thread | ||
249 | - NSAutoreleasePool *pool; | ||
250 | - | ||
251 | // Will be YES when a HEAD request will handle the content-length before this request starts | 248 | // Will be YES when a HEAD request will handle the content-length before this request starts |
252 | BOOL shouldResetProgressIndicators; | 249 | BOOL shouldResetProgressIndicators; |
253 | 250 |
@@ -436,12 +436,12 @@ static BOOL isiPhoneOS2; | @@ -436,12 +436,12 @@ static BOOL isiPhoneOS2; | ||
436 | // Create the request | 436 | // Create the request |
437 | - (void)main | 437 | - (void)main |
438 | { | 438 | { |
439 | - [pool release]; | 439 | + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
440 | - pool = [[NSAutoreleasePool alloc] init]; | ||
441 | [self setComplete:NO]; | 440 | [self setComplete:NO]; |
442 | 441 | ||
443 | if (![self url]) { | 442 | if (![self url]) { |
444 | [self failWithError:ASIUnableToCreateRequestError]; | 443 | [self failWithError:ASIUnableToCreateRequestError]; |
444 | + [pool release]; | ||
445 | return; | 445 | return; |
446 | } | 446 | } |
447 | 447 | ||
@@ -459,6 +459,7 @@ static BOOL isiPhoneOS2; | @@ -459,6 +459,7 @@ static BOOL isiPhoneOS2; | ||
459 | request = CFHTTPMessageCreateRequest(kCFAllocatorDefault, (CFStringRef)[self requestMethod], (CFURLRef)[self url], [self useHTTPVersionOne] ? kCFHTTPVersion1_0 : kCFHTTPVersion1_1); | 459 | request = CFHTTPMessageCreateRequest(kCFAllocatorDefault, (CFStringRef)[self requestMethod], (CFURLRef)[self url], [self useHTTPVersionOne] ? kCFHTTPVersion1_0 : kCFHTTPVersion1_1); |
460 | if (!request) { | 460 | if (!request) { |
461 | [self failWithError:ASIUnableToCreateRequestError]; | 461 | [self failWithError:ASIUnableToCreateRequestError]; |
462 | + [pool release]; | ||
462 | return; | 463 | return; |
463 | } | 464 | } |
464 | 465 | ||
@@ -481,6 +482,8 @@ static BOOL isiPhoneOS2; | @@ -481,6 +482,8 @@ static BOOL isiPhoneOS2; | ||
481 | } | 482 | } |
482 | 483 | ||
483 | [self loadRequest]; | 484 | [self loadRequest]; |
485 | + [pool release]; | ||
486 | + | ||
484 | } | 487 | } |
485 | 488 | ||
486 | - (void)applyAuthorizationHeader | 489 | - (void)applyAuthorizationHeader |
@@ -786,6 +789,7 @@ static BOOL isiPhoneOS2; | @@ -786,6 +789,7 @@ static BOOL isiPhoneOS2; | ||
786 | 789 | ||
787 | // Wait for the request to finish | 790 | // Wait for the request to finish |
788 | while (!complete) { | 791 | while (!complete) { |
792 | + | ||
789 | 793 | ||
790 | // We won't let the request cancel until we're done with this cycle of the loop | 794 | // We won't let the request cancel until we're done with this cycle of the loop |
791 | [[self cancelledLock] lock]; | 795 | [[self cancelledLock] lock]; |
@@ -797,13 +801,11 @@ static BOOL isiPhoneOS2; | @@ -797,13 +801,11 @@ static BOOL isiPhoneOS2; | ||
797 | break; | 801 | break; |
798 | } | 802 | } |
799 | 803 | ||
800 | - // This may take a while, so we'll release the pool each cycle to stop a giant backlog of autoreleased objects building up | 804 | + // This may take a while, so we'll create a new pool each cycle to stop a giant backlog of autoreleased objects building up |
801 | - [pool release]; | 805 | + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
802 | - pool = [[NSAutoreleasePool alloc] init]; | ||
803 | 806 | ||
804 | - NSDate *now = [NSDate date]; | ||
805 | 807 | ||
806 | - | 808 | + NSDate *now = [NSDate date]; |
807 | 809 | ||
808 | // See if we need to timeout | 810 | // See if we need to timeout |
809 | if (lastActivityTime && timeOutSeconds > 0 && [now timeIntervalSinceDate:lastActivityTime] > timeOutSeconds) { | 811 | if (lastActivityTime && timeOutSeconds > 0 && [now timeIntervalSinceDate:lastActivityTime] > timeOutSeconds) { |
@@ -816,6 +818,7 @@ static BOOL isiPhoneOS2; | @@ -816,6 +818,7 @@ static BOOL isiPhoneOS2; | ||
816 | [self cancelLoad]; | 818 | [self cancelLoad]; |
817 | [self setComplete:YES]; | 819 | [self setComplete:YES]; |
818 | [[self cancelledLock] unlock]; | 820 | [[self cancelledLock] unlock]; |
821 | + [pool release]; | ||
819 | break; | 822 | break; |
820 | } | 823 | } |
821 | } | 824 | } |
@@ -836,6 +839,7 @@ static BOOL isiPhoneOS2; | @@ -836,6 +839,7 @@ static BOOL isiPhoneOS2; | ||
836 | 839 | ||
837 | [self main]; | 840 | [self main]; |
838 | } | 841 | } |
842 | + [pool release]; | ||
839 | break; | 843 | break; |
840 | } | 844 | } |
841 | 845 | ||
@@ -861,9 +865,10 @@ static BOOL isiPhoneOS2; | @@ -861,9 +865,10 @@ static BOOL isiPhoneOS2; | ||
861 | 865 | ||
862 | [[self cancelledLock] unlock]; | 866 | [[self cancelledLock] unlock]; |
863 | 867 | ||
868 | + [pool release]; | ||
869 | + | ||
864 | } | 870 | } |
865 | - [pool release]; | 871 | + |
866 | - pool = nil; | ||
867 | } | 872 | } |
868 | 873 | ||
869 | // Cancel loading and clean up. DO NOT USE THIS TO CANCEL REQUESTS - use [request cancel] instead | 874 | // Cancel loading and clean up. DO NOT USE THIS TO CANCEL REQUESTS - use [request cancel] instead |
-
Please register or login to post a comment