This is hopefully a fix for a bizzare crash that seemed to appear on Snow Leopar…
…d where readstreams seemed to be generating events after they should have been cleaned up I think this might be related to the fact that NSOperationQueues in SN reuse threads, and so different requests may get the same runloop Also fix typo from last commit
Showing
1 changed file
with
4 additions
and
4 deletions
| @@ -752,7 +752,7 @@ static NSRecursiveLock *delegateAuthenticationLock = nil; | @@ -752,7 +752,7 @@ static NSRecursiveLock *delegateAuthenticationLock = nil; | ||
| 752 | [ASIHTTPRequest measureBandwidthUsage]; | 752 | [ASIHTTPRequest measureBandwidthUsage]; |
| 753 | 753 | ||
| 754 | // This thread should wait for 1/4 second for the stream to do something. We'll stop early if it does. | 754 | // This thread should wait for 1/4 second for the stream to do something. We'll stop early if it does. |
| 755 | - CFRunLoopRunInMode(ASIHTTPRequestRunMode,0,YES); | 755 | + CFRunLoopRunInMode(ASIHTTPRequestRunMode,0.25,YES); |
| 756 | } | 756 | } |
| 757 | 757 | ||
| 758 | [pool release]; | 758 | [pool release]; |
| @@ -764,9 +764,9 @@ static NSRecursiveLock *delegateAuthenticationLock = nil; | @@ -764,9 +764,9 @@ static NSRecursiveLock *delegateAuthenticationLock = nil; | ||
| 764 | { | 764 | { |
| 765 | [[self cancelledLock] lock]; | 765 | [[self cancelledLock] lock]; |
| 766 | if (readStream) { | 766 | if (readStream) { |
| 767 | - CFReadStreamClose(readStream); | ||
| 768 | CFReadStreamSetClient(readStream, kCFStreamEventNone, NULL, NULL); | 767 | CFReadStreamSetClient(readStream, kCFStreamEventNone, NULL, NULL); |
| 769 | CFReadStreamUnscheduleFromRunLoop(readStream, CFRunLoopGetCurrent(), ASIHTTPRequestRunMode); | 768 | CFReadStreamUnscheduleFromRunLoop(readStream, CFRunLoopGetCurrent(), ASIHTTPRequestRunMode); |
| 769 | + CFReadStreamClose(readStream); | ||
| 770 | CFRelease(readStream); | 770 | CFRelease(readStream); |
| 771 | readStream = NULL; | 771 | readStream = NULL; |
| 772 | } | 772 | } |
| @@ -1964,9 +1964,9 @@ static NSRecursiveLock *delegateAuthenticationLock = nil; | @@ -1964,9 +1964,9 @@ static NSRecursiveLock *delegateAuthenticationLock = nil; | ||
| 1964 | 1964 | ||
| 1965 | [[self cancelledLock] lock]; | 1965 | [[self cancelledLock] lock]; |
| 1966 | if (readStream) { | 1966 | if (readStream) { |
| 1967 | - CFReadStreamClose(readStream); | ||
| 1968 | CFReadStreamSetClient(readStream, kCFStreamEventNone, NULL, NULL); | 1967 | CFReadStreamSetClient(readStream, kCFStreamEventNone, NULL, NULL); |
| 1969 | CFReadStreamUnscheduleFromRunLoop(readStream, CFRunLoopGetCurrent(), ASIHTTPRequestRunMode); | 1968 | CFReadStreamUnscheduleFromRunLoop(readStream, CFRunLoopGetCurrent(), ASIHTTPRequestRunMode); |
| 1969 | + CFReadStreamClose(readStream); | ||
| 1970 | CFRelease(readStream); | 1970 | CFRelease(readStream); |
| 1971 | readStream = NULL; | 1971 | readStream = NULL; |
| 1972 | } | 1972 | } |
| @@ -2007,7 +2007,7 @@ static NSRecursiveLock *delegateAuthenticationLock = nil; | @@ -2007,7 +2007,7 @@ static NSRecursiveLock *delegateAuthenticationLock = nil; | ||
| 2007 | if (!fileError) { | 2007 | if (!fileError) { |
| 2008 | [[NSFileManager defaultManager] moveItemAtPath:[self temporaryFileDownloadPath] toPath:[self downloadDestinationPath] error:&moveError]; | 2008 | [[NSFileManager defaultManager] moveItemAtPath:[self temporaryFileDownloadPath] toPath:[self downloadDestinationPath] error:&moveError]; |
| 2009 | if (moveError) { | 2009 | if (moveError) { |
| 2010 | - fileError = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASIFileManagementError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Failed to move file from '%@' to '%@'",[self temporaryFileDownloadPath]],[self downloadDestinationPath],NSLocalizedDescriptionKey,moveError,NSUnderlyingErrorKey,nil]]; | 2010 | + fileError = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASIFileManagementError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Failed to move file from '%@' to '%@'",[self temporaryFileDownloadPath],[self downloadDestinationPath]],NSLocalizedDescriptionKey,moveError,NSUnderlyingErrorKey,nil]]; |
| 2011 | } | 2011 | } |
| 2012 | [self setTemporaryFileDownloadPath:nil]; | 2012 | [self setTemporaryFileDownloadPath:nil]; |
| 2013 | } | 2013 | } |
-
Please register or login to post a comment