Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed the locking mechanism, changed the run loops so they terminate;…

… this fixes bug #237

Signed-off-by: Jonathan 'Wolf' Rentzsch <jwr.git@redshed.net>
  • Loading branch information...
commit f6c59488db93286f97252ef10fd2e438bb8fc25a 1 parent cf7d286
Simone Manganelli authored committed
Showing with 4 additions and 10 deletions.
  1. +4 −10 Plugin/CTFURLConnection.m
14 Plugin/CTFURLConnection.m
View
@@ -61,15 +61,13 @@ + (NSHTTPURLResponse *)getURLResponseHeaders:(NSURL *)URL
- (void)startRequest:(NSURLRequest *)request;
{
-
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[request retain];
- NSLog(@"Connection is starting immediately.");
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request
delegate:self
startImmediately:YES];
- [[NSRunLoop currentRunLoop] run];
+ [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:10]];
[connection release];
[request release];
@@ -79,8 +77,7 @@ - (void)startRequest:(NSURLRequest *)request;
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error;
{
- NSLog(@"Connection failed with error: %@",error);
- [theLock tryLock];
+ [theLock lock];
errorToReturn = error;
[theLock unlockWithCondition:1];
@@ -88,8 +85,7 @@ - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)err
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSHTTPURLResponse *)theResponse;
{
-
- [theLock tryLock];
+ [theLock lock];
// we cancel here, because otherwise NSURLConnection will continue to download
// data due to a bug; even though we made a HEAD request, it still downloads
@@ -97,13 +93,11 @@ - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSHTTPURLRe
[connection cancel];
responseToReturn = [theResponse retain];
[theLock unlockWithCondition:1];
-
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection;
{
- NSLog(@"Connection did finish loading.");
- [theLock tryLock];
+ [theLock lock];
[theLock unlockWithCondition:1];
}
Please sign in to comment.
Something went wrong with that request. Please try again.