2007-11-11  Yavor Doganov  <yavor@gnu.org>

	* Source/NSDistributedNotificationCenter.m 
	(NSDistributedNotificationCenter -_connect): Loop for one second
	right after gdnc is launched.  Check for the port presence using
	portForName:onHost: before attemtpting the connection.  Do not
	retry [NSConnection +rootProxyForConnectionWithRegisteredName:];
	either the speaking port is there and it will succeed or there's a
	deeper problem.
	<limit>: Increase to 10 seconds.

--- Source/NSDistributedNotificationCenter.m	2007-03-06 20:38:22.000000000 +0200
+++ Source/NSDistributedNotificationCenter.m	2007-11-11 02:27:39.000000000 +0200
@@ -736,13 +736,24 @@ static NSDistributedNotificationCenter	*
 	    }
 	  [NSTask launchedTaskWithLaunchPath: cmd arguments: args];
 
-	  limit = [NSDate dateWithTimeIntervalSinceNow: 5.0];
+	  /* Wait for the port to become live, before attempting
+	     connection.  */
+	  limit = [NSDate dateWithTimeIntervalSinceNow: 10.0];
+	  while (_remote == nil && [limit timeIntervalSinceNow] > 9)
+	    {
+	      NSDebugMLLog(@"NSDistributedNotificationCenter",
+			   @"Holding on while a speaking port is created.\n");
+	    }
 	  while (_remote == nil && [limit timeIntervalSinceNow] > 0)
 	    {
-	      _remote = [NSConnection
-		rootProxyForConnectionWithRegisteredName: service
-		host: host usingNameServer: ns];
+	      if ([ns portForName: service onHost: nil])
+		break;
 	    }
+	  NSDebugMLLog(@"NSDistributedNotificationCenter",
+		       @"Attempting connection to the GDNC server...\n");
+	  _remote = [NSConnection
+	    rootProxyForConnectionWithRegisteredName: service
+	    host: host usingNameServer: ns];
 	  if (_remote == nil)
 	    {
 	      [NSException raise: NSInternalInconsistencyException
