From 0e6f0a85764303913cde7b247ba2650e961805c1 Mon Sep 17 00:00:00 2001 From: vspader Date: Sun, 14 Oct 2007 16:37:06 +0000 Subject: [PATCH] Fixed up thread handling. --- Plugins/HTTPSource/HTTPSource.m | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Plugins/HTTPSource/HTTPSource.m b/Plugins/HTTPSource/HTTPSource.m index 897eb9bad..e6a1adf70 100644 --- a/Plugins/HTTPSource/HTTPSource.m +++ b/Plugins/HTTPSource/HTTPSource.m @@ -34,9 +34,15 @@ _connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; [request release]; + + NSDate* endDate = [NSDate distantFuture]; + do + { + NSLog(@"IN THREAD"); + [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:endDate]; + } while (!_connectionFinished); - [[NSRunLoop currentRunLoop] run]; - + NSLog(@"Exiting thread"); } - (NSDictionary *)properties @@ -62,7 +68,6 @@ - (int)read:(void *)buffer amount:(int)amount { while (amount > [_data length] && !_connectionFinished) { - NSLog(@"Waiting: %@", [NSThread currentThread]); [_sem timedWait: 2]; } @@ -96,6 +101,8 @@ - (void)close { + _connectionFinished = YES; + [_connection cancel]; [_connection release]; _connection = nil;