Author: rfm
Date: Fri Jun 24 12:44:40 2016
New Revision: 39917

URL: http://svn.gna.org/viewcvs/gnustep?rev=39917&view=rev
Log:
Improve reliability on a slow system where there is no gdnc daemon (eg when
running regression tests for an uninstalled copy of gnustep).

Modified:
    libs/base/trunk/Source/NSDistributedNotificationCenter.m
    libs/base/trunk/Tools/gdnc.m

Modified: libs/base/trunk/Source/NSDistributedNotificationCenter.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/NSDistributedNotificationCenter.m?rev=39917&r1=39916&r2=39917&view=diff
==============================================================================
--- libs/base/trunk/Source/NSDistributedNotificationCenter.m    (original)
+++ libs/base/trunk/Source/NSDistributedNotificationCenter.m    Fri Jun 24 
12:44:40 2016
@@ -736,7 +736,7 @@
            }
          [NSTask launchedTaskWithLaunchPath: cmd arguments: args];
 
-         limit = [NSDate dateWithTimeIntervalSinceNow: 5.0];
+         limit = [NSDate dateWithTimeIntervalSinceNow: 10.0];
          while (_remote == nil && [limit timeIntervalSinceNow] > 0)
            {
               NSAutoreleasePool        *pool = [NSAutoreleasePool new];

Modified: libs/base/trunk/Tools/gdnc.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Tools/gdnc.m?rev=39917&r1=39916&r2=39917&view=diff
==============================================================================
--- libs/base/trunk/Tools/gdnc.m        (original)
+++ libs/base/trunk/Tools/gdnc.m        Fri Jun 24 12:44:40 2016
@@ -37,6 +37,7 @@
 #import        "Foundation/NSProcessInfo.h"
 #import        "Foundation/NSRunLoop.h"
 #import        "Foundation/NSTask.h"
+#import        "Foundation/NSTimer.h"
 #import        "Foundation/NSUserDefaults.h"
 
 
@@ -68,6 +69,8 @@
 static BOOL    debugging = NO;
 static BOOL    is_daemon = NO;         /* Currently running as daemon.  */
 static BOOL    auto_stop = NO;         /* Should we shut down when unused? */
+
+static NSTimer  *timer = nil;           /* When to shut down. */
 
 #if defined(HAVE_SYSLOG) || defined(HAVE_SLOGF)
 #  if defined(HAVE_SLOGF)
@@ -358,6 +361,20 @@
 
 @implementation        GDNCServer
 
+- (void) autoStop: (NSTimer*)t
+{
+  if (t == timer)
+    {
+      timer = nil;
+    }
+  if (auto_stop == YES && NSCountMapTable(connections) == 0)
+    {
+      /* There is nothing else using this process, stop.
+       */
+      exit(EXIT_SUCCESS);
+    }
+}
+
 - (void) dealloc
 {
   NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
@@ -662,6 +679,11 @@
   table = NSCreateMapTable(NSObjectMapKeyCallBacks,
                NSObjectMapValueCallBacks, 0);
   NSMapInsert(connections, newConn, table);
+  if (nil != timer)
+    {
+      [timer invalidate];
+      timer = nil;
+    }
   return YES;
 }
 
@@ -697,10 +719,19 @@
 
       if (auto_stop == YES && NSCountMapTable(connections) == 0)
         {
-         /* If there is nothing else using this process, and this is not
-          * a daemon, then we can quietly terminate.
-          */
-          exit(EXIT_SUCCESS);
+          /* There is nothing left using this notification center,
+           * so schedule the auto_stop to occur in a short while
+           * if nothing has connected to us.
+           */
+          if (nil != timer)
+            {
+              [timer invalidate];
+            }
+          timer = [NSTimer scheduledTimerWithTimeInterval: 15.0
+                                                   target: self
+                                                 selector: @selector(autoStop:)
+                                                 userInfo: nil
+                                                  repeats: NO];
        }
     }
   return nil;


_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to