- (void)checkForRemoteServerAndConnectImmediately:(BOOL)connectImmediately
{
ITDebugLog(@"Checking for remote server.");
- [NSThread detachNewThreadSelector:@selector(runRemoteServerCheck:) toTarget:self withObject:[NSNumber numberWithBool:connectImmediately]];
+ if (!_checkingForServer) {
+ if (!_serverCheckLock) {
+ _serverCheckLock = [[NSLock alloc] init];
+ }
+ [_serverCheckLock lock];
+ _checkingForServer = YES;
+ [_serverCheckLock unlock];
+ [NSThread detachNewThreadSelector:@selector(runRemoteServerCheck:) toTarget:self withObject:[NSNumber numberWithBool:connectImmediately]];
+ }
}
- (void)runRemoteServerCheck:(id)sender
ITDebugLog(@"Remote server not found.");
[self performSelectorOnMainThread:@selector(remoteServerNotFound:) withObject:nil waitUntilDone:NO];
}
+ [_serverCheckLock lock];
+ _checkingForServer = NO;
+ [_serverCheckLock unlock];
[pool release];
}
[statusWindowController release];
[menuController release];
[networkController release];
+ [_serverCheckLock release];
[super dealloc];
}