git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/ec/trunk@37889 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2014-05-16 22:13:43 +00:00
parent 3f204d7a83
commit f45c83caed
2 changed files with 90 additions and 72 deletions

View file

@ -6,6 +6,9 @@
* EcLogger.m: Use floating point flush interval for modern * EcLogger.m: Use floating point flush interval for modern
systems which run faster and might want to flush more than systems which run faster and might want to flush more than
once per second. once per second.
* EcProcess.m: Don't start handling timeouts until the
process is actually running (so we don't get any during
initialisation of the class).
* GNUmakefile: bump subminor version number for release * GNUmakefile: bump subminor version number for release
Version 1.1.3 release Version 1.1.3 release

View file

@ -105,6 +105,7 @@ static NSRecursiveLock *ecLock = nil;
static BOOL cmdFlagDaemon = NO; static BOOL cmdFlagDaemon = NO;
static BOOL cmdFlagTesting = NO; static BOOL cmdFlagTesting = NO;
static BOOL cmdIsQuitting = NO; static BOOL cmdIsQuitting = NO;
static BOOL cmdIsRunning = NO;
static NSInteger cmdQuitStatus = 0; static NSInteger cmdQuitStatus = 0;
static NSString *cmdInst = nil; static NSString *cmdInst = nil;
static NSString *cmdName = nil; static NSString *cmdName = nil;
@ -2299,7 +2300,7 @@ NSLog(@"Ignored attempt to set timer interval to %g ... using 10.0", interval);
arp = [NSAutoreleasePool new]; arp = [NSAutoreleasePool new];
if (YES == cmdIsTransient) if (YES == cmdIsTransient)
{ {
[self cmdWarn: @"Attempted to run transient process."]; [self cmdWarn: @"Attempted to run transient process."];
[self cmdFlushLogs]; [self cmdFlushLogs];
[arp release]; [arp release];
return 1; return 1;
@ -2347,6 +2348,7 @@ NSLog(@"Ignored attempt to set timer interval to %g ... using 10.0", interval);
[self cmdAudit: @"Started `%@'", [self cmdName]]; [self cmdAudit: @"Started `%@'", [self cmdName]];
[self cmdFlushLogs]; [self cmdFlushLogs];
cmdIsRunning = YES;
loop = [NSRunLoop currentRunLoop]; loop = [NSRunLoop currentRunLoop];
while (YES == [EcProcConnection isValid]) while (YES == [EcProcConnection isValid])
@ -2379,9 +2381,9 @@ NSLog(@"Ignored attempt to set timer interval to %g ... using 10.0", interval);
[arp release]; [arp release];
/* finish server */ /* finish server */
cmdIsQuitting = YES; cmdIsQuitting = YES;
[self cmdQuit: 0]; [self cmdQuit: 0];
cmdIsRunning = NO;
DESTROY(EcProcConnection); DESTROY(EcProcConnection);
return 0; return 0;
} }
@ -4119,7 +4121,11 @@ NSLog(@"Ignored attempt to set timer interval to %g ... using 10.0", interval);
cmdIsQuitting = YES; cmdIsQuitting = YES;
[self cmdQuit: sig]; [self cmdQuit: sig];
} }
if (YES == inProgress) if (YES == cmdIsQuitting)
{
NSLog(@"_timedOut: ignored because process is quitting");
}
else if (YES == inProgress)
{ {
NSLog(@"_timedOut: ignored because timeout already in progress"); NSLog(@"_timedOut: ignored because timeout already in progress");
} }
@ -4128,76 +4134,85 @@ NSLog(@"Ignored attempt to set timer interval to %g ... using 10.0", interval);
BOOL delay = NO; BOOL delay = NO;
inProgress = YES; inProgress = YES;
NS_DURING
{
NSCalendarDate *now = [NSCalendarDate date];
static int lastDay = 0;
static int lastHour = 0;
static int lastMinute = 0;
static int lastTenSecond = 0;
BOOL newDay = NO;
BOOL newHour = NO;
BOOL newMinute = NO;
BOOL newTenSecond = NO;
int i;
i = [now dayOfWeek]; /* We only perform timeouts if the process is actually
if (i != lastDay) * running (don't want them during startup before the
{ * thing is fully initialised.
lastDay = i; * So if not running, skip to scheduling next timeout.
newDay = YES; */
newHour = YES; if (YES == cmdIsRunning)
newMinute = YES; {
newTenSecond = YES; NS_DURING
} {
i = [now hourOfDay]; NSCalendarDate *now = [NSCalendarDate date];
if (i != lastHour) static int lastDay = 0;
{ static int lastHour = 0;
lastHour = i; static int lastMinute = 0;
newHour = YES; static int lastTenSecond = 0;
newMinute = YES; BOOL newDay = NO;
newTenSecond = YES; BOOL newHour = NO;
} BOOL newMinute = NO;
i = [now minuteOfHour]; BOOL newTenSecond = NO;
if (i != lastMinute) int i;
{
lastMinute = i; i = [now dayOfWeek];
newMinute = YES; if (i != lastDay)
newTenSecond = YES; {
} lastDay = i;
i = [now secondOfMinute] / 10; newDay = YES;
if (i != lastTenSecond) newHour = YES;
{ newMinute = YES;
lastTenSecond = i; newTenSecond = YES;
newTenSecond = YES; }
} i = [now hourOfDay];
if (YES == newTenSecond) if (i != lastHour)
{ {
[self cmdNewServer]; lastHour = i;
} newHour = YES;
if (YES == newMinute) newMinute = YES;
{ newTenSecond = YES;
[self ecNewMinute: now]; }
} i = [now minuteOfHour];
if (YES == newHour) if (i != lastMinute)
{ {
[self ecNewHour: now]; lastMinute = i;
} newMinute = YES;
if (YES == newDay) newTenSecond = YES;
{ }
[self ecNewDay: now]; i = [now secondOfMinute] / 10;
} if (i != lastTenSecond)
if (cmdTimSelector != 0) {
{ lastTenSecond = i;
[self performSelector: cmdTimSelector]; newTenSecond = YES;
} }
} if (YES == newTenSecond)
NS_HANDLER {
{ [self cmdNewServer];
NSLog(@"Exception performing regular timeout: %@", localException); }
delay = YES; // Avoid runaway logging. if (YES == newMinute)
} {
NS_ENDHANDLER [self ecNewMinute: now];
}
if (YES == newHour)
{
[self ecNewHour: now];
}
if (YES == newDay)
{
[self ecNewDay: now];
}
if (cmdTimSelector != 0)
{
[self performSelector: cmdTimSelector];
}
}
NS_HANDLER
{
NSLog(@"Exception performing regular timeout: %@", localException);
delay = YES; // Avoid runaway logging.
}
NS_ENDHANDLER
}
if (cmdPTimer == nil) if (cmdPTimer == nil)
{ {