Ben Copsey

Move clearing the timer for safety. Can't imagine why this wasn't showing up before

@@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
21 #import "ASIInputStream.h" 21 #import "ASIInputStream.h"
22 22
23 // Automatically set on build 23 // Automatically set on build
24 -NSString *ASIHTTPRequestVersion = @"v1.2-69 2010-01-06"; 24 +NSString *ASIHTTPRequestVersion = @"v1.2-70 2010-01-06";
25 25
26 NSString* const NetworkRequestErrorDomain = @"ASIHTTPRequestErrorDomain"; 26 NSString* const NetworkRequestErrorDomain = @"ASIHTTPRequestErrorDomain";
27 27
@@ -921,7 +921,7 @@ static BOOL isiPhoneOS2; @@ -921,7 +921,7 @@ static BOOL isiPhoneOS2;
921 break; 921 break;
922 } else { 922 } else {
923 #if DEBUG_PERSISTENT_CONNECTIONS 923 #if DEBUG_PERSISTENT_CONNECTIONS
924 - NSLog(@"Not re-using connection #%hi because it has expired",[[connectionInfo objectForKey:@"id"] intValue]); 924 + NSLog(@"Not re-using connection #%hi because it has expired",[[existingConnection objectForKey:@"id"] intValue]);
925 #endif 925 #endif
926 [persistentConnectionsPool removeObject:existingConnection]; 926 [persistentConnectionsPool removeObject:existingConnection];
927 i--; 927 i--;
@@ -1034,13 +1034,17 @@ static BOOL isiPhoneOS2; @@ -1034,13 +1034,17 @@ static BOOL isiPhoneOS2;
1034 1034
1035 - (void)setStatusTimer:(NSTimer *)timer 1035 - (void)setStatusTimer:(NSTimer *)timer
1036 { 1036 {
  1037 + [self retain];
1037 // We must invalidate the old timer here, not before we've created and scheduled a new timer 1038 // We must invalidate the old timer here, not before we've created and scheduled a new timer
1038 // This is because the timer may be the only thing retaining an asynchronous request 1039 // This is because the timer may be the only thing retaining an asynchronous request
1039 if ([self statusTimer] && timer != [self statusTimer]) { 1040 if ([self statusTimer] && timer != [self statusTimer]) {
  1041 +
1040 [[self statusTimer] invalidate]; 1042 [[self statusTimer] invalidate];
1041 [[self statusTimer] release]; 1043 [[self statusTimer] release];
  1044 +
1042 } 1045 }
1043 statusTimer = [timer retain]; 1046 statusTimer = [timer retain];
  1047 + [self release];
1044 } 1048 }
1045 1049
1046 - (void)performRedirect 1050 - (void)performRedirect
@@ -2351,8 +2355,13 @@ static BOOL isiPhoneOS2; @@ -2351,8 +2355,13 @@ static BOOL isiPhoneOS2;
2351 } 2355 }
2352 2356
2353 [self performThrottling]; 2357 [self performThrottling];
  2358 +
2354 [[self cancelledLock] unlock]; 2359 [[self cancelledLock] unlock];
2355 2360
  2361 + if (![self inProgress]) {
  2362 + [self setStatusTimer:nil];
  2363 + }
  2364 +
2356 } 2365 }
2357 2366
2358 2367
@@ -2532,7 +2541,6 @@ static BOOL isiPhoneOS2; @@ -2532,7 +2541,6 @@ static BOOL isiPhoneOS2;
2532 [self didChangeValueForKey:@"isFinished"]; 2541 [self didChangeValueForKey:@"isFinished"];
2533 [self setInProgress:NO]; 2542 [self setInProgress:NO];
2534 CFRunLoopStop(CFRunLoopGetCurrent()); 2543 CFRunLoopStop(CFRunLoopGetCurrent());
2535 - [self setStatusTimer:nil];  
2536 2544
2537 } 2545 }
2538 2546