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
12 additions
and
12 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,11 +764,11 @@ static NSRecursiveLock *delegateAuthenticationLock = nil; | @@ -764,11 +764,11 @@ static NSRecursiveLock *delegateAuthenticationLock = nil; | ||
764 | { | 764 | { |
765 | [[self cancelledLock] lock]; | 765 | [[self cancelledLock] lock]; |
766 | if (readStream) { | 766 | if (readStream) { |
767 | - CFReadStreamClose(readStream); | 767 | + CFReadStreamSetClient(readStream, kCFStreamEventNone, NULL, NULL); |
768 | - CFReadStreamSetClient(readStream, kCFStreamEventNone, NULL, NULL); | 768 | + CFReadStreamUnscheduleFromRunLoop(readStream, CFRunLoopGetCurrent(), ASIHTTPRequestRunMode); |
769 | - CFReadStreamUnscheduleFromRunLoop(readStream, CFRunLoopGetCurrent(), ASIHTTPRequestRunMode); | 769 | + CFReadStreamClose(readStream); |
770 | - CFRelease(readStream); | 770 | + CFRelease(readStream); |
771 | - readStream = NULL; | 771 | + readStream = NULL; |
772 | } | 772 | } |
773 | 773 | ||
774 | [[self postBodyReadStream] close]; | 774 | [[self postBodyReadStream] close]; |
@@ -1964,11 +1964,11 @@ static NSRecursiveLock *delegateAuthenticationLock = nil; | @@ -1964,11 +1964,11 @@ static NSRecursiveLock *delegateAuthenticationLock = nil; | ||
1964 | 1964 | ||
1965 | [[self cancelledLock] lock]; | 1965 | [[self cancelledLock] lock]; |
1966 | if (readStream) { | 1966 | if (readStream) { |
1967 | - CFReadStreamClose(readStream); | 1967 | + CFReadStreamSetClient(readStream, kCFStreamEventNone, NULL, NULL); |
1968 | - CFReadStreamSetClient(readStream, kCFStreamEventNone, NULL, NULL); | 1968 | + CFReadStreamUnscheduleFromRunLoop(readStream, CFRunLoopGetCurrent(), ASIHTTPRequestRunMode); |
1969 | - CFReadStreamUnscheduleFromRunLoop(readStream, CFRunLoopGetCurrent(), ASIHTTPRequestRunMode); | 1969 | + CFReadStreamClose(readStream); |
1970 | - CFRelease(readStream); | 1970 | + CFRelease(readStream); |
1971 | - readStream = NULL; | 1971 | + readStream = NULL; |
1972 | } | 1972 | } |
1973 | 1973 | ||
1974 | [[self postBodyReadStream] close]; | 1974 | [[self postBodyReadStream] close]; |
@@ -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