diff --git a/Control.plist b/Control.plist index ce577c3..8f67d1e 100644 --- a/Control.plist +++ b/Control.plist @@ -56,8 +56,9 @@ * ValgrindPath = (string) Run under valgrind (unless empty) * ValgrindArgs = (array) Run under valgrind using these args * - * Ping = (integer) If greater than zero, this is the ping delay in - * seconds (otherwise the default ofd 240 is used). + * PingTime = (integer) If greater than zero, this is the ping delay in + * seconds (otherwise the default of 240 is used, + * or as specified by the CommandPingTime default). * When a process has been unresponsive to the * Command server for this number of seconds, that * process is considered to be hung. @@ -70,6 +71,12 @@ * after HungTime in order to gather information * about the hung process. It's arguments will * be the process name and the process ID. + * QuitTime = (integer) If greater than zero this the interval before + * a process is forcably killed if it is stopping + * or restarting too slowly. The default (used + * if this is not specified and greater than zero) + * is 120 seconds (or as specified by the + * CommandQuitTime default). */ Foo = { Prog = "/usr/GNUstep/Local/Tools/Foo"; // Full path to binary diff --git a/EcCommand.m b/EcCommand.m index 3df2f09..ae29b85 100644 --- a/EcCommand.m +++ b/EcCommand.m @@ -60,7 +60,7 @@ static const NSTimeInterval day = 24.0 * 60.0 * 60.0; static int tStatus = 0; -static NSTimeInterval pingDelay = 240.0; +static NSTimeInterval pingTime = 240.0; static int comp_len = 0; @@ -113,23 +113,6 @@ static NSTimeInterval quitTime = 120.0; */ static NSDate *terminateBy = nil; -static NSTimeInterval -abortDateFromStoppingDate(NSTimeInterval stopping) -{ - NSTimeInterval abortDate = stopping + quitTime; - - if (terminateBy) - { - NSTimeInterval ti = [terminateBy timeIntervalSinceReferenceDate]; - - if (ti < abortDate) - { - abortDate = ti; - } - } - return abortDate; -} - static NSUInteger launchLimit = 0; static BOOL launchEnabled = NO; static NSMutableDictionary *launchInfo = nil; @@ -845,6 +828,33 @@ desiredName(Desired state) } } +- (NSTimeInterval) abortDateFromStoppingDate: (NSTimeInterval)stopping +{ + NSTimeInterval when = stopping; + NSTimeInterval ti = 0.0; + NSString *s; + + s = [[self configuration] objectForKey: @"QuitTime"]; + if ([s respondsToSelector: @selector(intValue)]) + { + ti = (NSTimeInterval)[s intValue]; + } + if (ti <= 0.0) + { + ti = quitTime; + } + when += ti; + if (terminateBy) + { + ti = [terminateBy timeIntervalSinceReferenceDate]; + if (ti < when) + { + when = ti; + } + } + return when; +} + - (void) alarm: (EcAlarm*)alarm { NSUInteger index; @@ -2540,7 +2550,7 @@ valgrindLog(NSString *name) { [self resetDelay]; stoppingDate = [NSDate timeIntervalSinceReferenceDate]; - abortDate = abortDateFromStoppingDate(stoppingDate); + abortDate = [self abortDateFromStoppingDate: stoppingDate]; if ([self hungDate] > 0.0 && identifier > 0) { /* The process is hung and we assume it can't shut down gracefully. @@ -2871,7 +2881,7 @@ valgrindLog(NSString *name) } if (abortDate <= 0.0) { - abortDate = abortDateFromStoppingDate(stoppingDate); + abortDate = [self abortDateFromStoppingDate: stoppingDate]; } if (abortDate <= now) { @@ -3501,6 +3511,21 @@ NSLog(@"Problem %@", localException); debug = [[d objectForKey: @"CommandDebug"] boolValue]; + /* The time allowed for a process to respond to pings defaults + * to 240 seconds but may be configured in the range from 10 to 600 + */ + ti = [[d objectForKey: @"CommandPingTime"] doubleValue]; + if (ti == ti && ti > 0.0) + { + if (ti < 10.0) ti = 10.0; + if (ti > 600.0) ti = 600.0; + pingTime = ti; + } + else + { + pingTime = 120.0; + } + /* The time allowed for a process to shut down cleanly defaults * to 120 seconds but may be configured in the range from 10 to 600 */ @@ -6022,14 +6047,14 @@ NSLog(@"Problem %@", localException); { continue; } - s = [[l configuration] objectForKey: @"Ping"]; + s = [[l configuration] objectForKey: @"PingTime"]; if ([s respondsToSelector: @selector(intValue)]) { delay = (NSTimeInterval)[s intValue]; } if (delay <= 0.0) { - delay = pingDelay; // Default + delay = pingTime; // Default } if (d != nil && [d timeIntervalSinceDate: now] < -delay) { @@ -6078,13 +6103,13 @@ NSLog(@"Problem %@", localException); [a removeAllObjects]; if (control != nil && outstanding != nil - && [outstanding timeIntervalSinceDate: now] < -pingDelay) + && [outstanding timeIntervalSinceDate: now] < -pingTime) { NSString *m; m = [NSString stringWithFormat: cmdLogFormat(LT_CONSOLE, @"Control server failed to respond for over %d seconds"), - (int)pingDelay]; + (int)pingTime]; [[(NSDistantObject*)control connectionForProxy] invalidate]; [self information: m from: nil to: nil type: LT_CONSOLE]; lost = YES;