mirror of
https://github.com/gnustep/libs-ec.git
synced 2025-02-15 16:11:01 +00:00
Make connection to process wait for regisdtration with Command server.
Add restart all option for Control git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/ec/trunk@40241 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e633a3437f
commit
86d618d0d9
2 changed files with 61 additions and 0 deletions
41
EcControl.m
41
EcControl.m
|
@ -1030,6 +1030,10 @@ static NSString* cmdWord(NSArray* a, unsigned int pos)
|
|||
{
|
||||
m = @"Repeat\nRepeat the last command.\n";
|
||||
}
|
||||
else if (comp(wd, @"Restart") >= 0)
|
||||
{
|
||||
m = @"Restart all\nAsks all hosts to restart servers.\n";
|
||||
}
|
||||
else if (comp(wd, @"Set") >= 0)
|
||||
{
|
||||
m = @"Set\n"
|
||||
|
@ -1201,6 +1205,43 @@ static NSString* cmdWord(NSArray* a, unsigned int pos)
|
|||
exit(0);
|
||||
}
|
||||
}
|
||||
else if (comp(wd, @"restart") >= 0)
|
||||
{
|
||||
wd = cmdWord(cmd, 1);
|
||||
if ([wd length] > 0 && comp(wd, @"all") == 0)
|
||||
{
|
||||
NSUInteger i;
|
||||
NSArray *hosts = [[commands copy] autorelease];
|
||||
|
||||
for (i = 0; i < [hosts count]; i++)
|
||||
{
|
||||
CommandInfo *c = [hosts objectAtIndex: i];
|
||||
|
||||
if ([commands indexOfObjectIdenticalTo: c] != NSNotFound)
|
||||
{
|
||||
NS_DURING
|
||||
{
|
||||
NSData *dat = [NSPropertyListSerialization
|
||||
dataFromPropertyList: cmd
|
||||
format: NSPropertyListBinaryFormat_v1_0
|
||||
errorDescription: 0];
|
||||
[[c obj] command: dat
|
||||
to: nil
|
||||
from: [console name]];
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
NSLog(@"Caught: %@", localException);
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m = @"Try 'restart all' or 'on host restart ...\n";
|
||||
}
|
||||
}
|
||||
else if (comp(wd, @"set") >= 0)
|
||||
{
|
||||
m = @"ok - set confirmed.\n";
|
||||
|
|
20
EcTest.m
20
EcTest.m
|
@ -138,6 +138,26 @@ EcTestConnect(NSString *name, NSString *host, NSTimeInterval timeout)
|
|||
}
|
||||
[NSThread sleepForTimeInterval: 0.1];
|
||||
}
|
||||
NS_DURING
|
||||
{
|
||||
if (YES == [(EcProcess*)proxy cmdIsClient])
|
||||
{
|
||||
if (NO == [(EcProcess*)proxy cmdIsConnected])
|
||||
{
|
||||
/* We must wait for the connected process to register
|
||||
* with the Command server and configure itself.
|
||||
*/
|
||||
proxy = nil;
|
||||
[NSThread sleepForTimeInterval: 0.1];
|
||||
}
|
||||
}
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
NSLog(@"Failed to communicate with '%@': %@",
|
||||
name, localException);
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
}
|
||||
[proxy retain];
|
||||
DESTROY(pool);
|
||||
|
|
Loading…
Reference in a new issue