1
0
Fork 0
forked from External/grumble

Check for server existance in ctlrpc.

This commit is contained in:
Mikkel Krautz 2011-05-13 15:42:06 +02:00
parent c785c45166
commit cfa9172e69

View file

@ -13,12 +13,22 @@ type ControlRPC struct {
}
// Start a server
func (c *ControlRPC) Start(in *int, out *int) os.Error {
func (c *ControlRPC) Start(Id int64, out *int) os.Error {
server, exists := servers[Id]
if !exists {
return os.NewError("no such server")
}
_ = server
return nil
}
// Stop a server
func (c *ControlRPC) Stop(in *int, out *int) os.Error {
func (c *ControlRPC) Stop(Id int64, out *int) os.Error {
server, exists := servers[Id]
if !exists {
return os.NewError("no such server")
}
_ = server
return nil
}
@ -30,7 +40,11 @@ type ConfigValue struct {
// Set a config value
func (c *ControlRPC) SetConfig(in *ConfigValue, out *ConfigValue) os.Error {
servers[in.Id].cfg.Set(in.Key, in.Value)
server, exists := servers[in.Id]
if !exists {
return os.NewError("no such server")
}
server.cfg.Set(in.Key, in.Value)
out.Id = in.Id
out.Key = in.Key
out.Value = in.Value
@ -39,8 +53,12 @@ func (c *ControlRPC) SetConfig(in *ConfigValue, out *ConfigValue) os.Error {
// Get a config value
func (c *ControlRPC) GetConfig(in *ConfigValue, out *ConfigValue) os.Error {
server, exists := servers[in.Id]
if !exists {
return os.NewError("no such server")
}
out.Id = in.Id
out.Key = in.Key
out.Value = servers[in.Id].cfg.StringValue(in.Key)
out.Value = server.cfg.StringValue(in.Key)
return nil
}