Author: rfm
Date: Thu Jan 15 13:20:27 2015
New Revision: 38291

URL: http://svn.gna.org/viewcvs/gnustep?rev=38291&view=rev
Log:
Tweak to allow quicker shutdown of processes when alarm destination is stuck

Modified:
    libs/ec/trunk/ChangeLog
    libs/ec/trunk/EcAlarmDestination.m

Modified: libs/ec/trunk/ChangeLog
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/ec/trunk/ChangeLog?rev=38291&r1=38290&r2=38291&view=diff
==============================================================================
--- libs/ec/trunk/ChangeLog     (original)
+++ libs/ec/trunk/ChangeLog     Thu Jan 15 13:20:27 2015
@@ -1,3 +1,10 @@
+2015-01-15  Richard Frith-Macdonald <[email protected]>
+
+        * EcAlarmDestination.m: When shutting down, only wait for the
+       background thread first time ... otherwise we could get into a
+       recursive loop calling the -shutdown method while
+       waiting for shutdown to complete.
+                               
 2015-01-07  Richard Frith-Macdonald <[email protected]>
 
        * configure.ac:

Modified: libs/ec/trunk/EcAlarmDestination.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/ec/trunk/EcAlarmDestination.m?rev=38291&r1=38290&r2=38291&view=diff
==============================================================================
--- libs/ec/trunk/EcAlarmDestination.m  (original)
+++ libs/ec/trunk/EcAlarmDestination.m  Thu Jan 15 13:20:27 2015
@@ -292,29 +292,38 @@
 
 - (void) shutdown
 {
-  NSDate       *begin;
-
-  [_alarmLock lock];
+  BOOL         wasShuttingDown;
+
+  [_alarmLock lock];
+  wasShuttingDown = _shouldStop;
   _shouldStop = YES;
   [_host release];
   _host = nil;
   [_name release];
   _name = nil;
   [_alarmLock unlock];
-  begin = [NSDate date];
-  while (YES == [self isRunning])
-    {
-      NSDate    *when;
-
-      if ([begin timeIntervalSinceNow] < -5.0)
-       {
-         NSLog(@"alarm thread failed to stop within 5 seconds");
-         return;
-       }
-      when = [[NSDate alloc] initWithTimeIntervalSinceNow: 0.1];
-      [[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode
-                               beforeDate: when];
-      [when release];
+  if (NO == wasShuttingDown)
+    {
+      NSDate   *begin;
+
+      /* Unless we are called recursively, lets wait for a while for
+       * the alarm thread to terminate.
+       */
+      begin = [NSDate date];
+      while (YES == [self isRunning])
+       {
+         NSDate    *when;
+
+         if ([begin timeIntervalSinceNow] < -5.0)
+           {
+             NSLog(@"alarm thread failed to stop within 5 seconds");
+             return;
+           }
+         when = [[NSDate alloc] initWithTimeIntervalSinceNow: 0.1];
+         [[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode
+                                  beforeDate: when];
+         [when release];
+       }
     }
 }
 


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

Reply via email to