Skip to content

Commit

Permalink
close log file handles when applying a configuration change
Browse files Browse the repository at this point in the history
we were leaking descriptors.
  • Loading branch information
gustavo-iniguez-goya committed Nov 2, 2020
1 parent ff5c1ff commit aad69e9
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions daemon/ui/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,17 @@ func (c *Client) loadConfiguration(rawConfig []byte) bool {
defer config.Unlock()

if err := json.Unmarshal(rawConfig, &config); err != nil {
fmt.Errorf("Error parsing configuration %s: %s", configFile, err)
log.Error("Error parsing configuration %s: %s", configFile, err)
return false
}
// firstly load config level, to detect further errors if any
if config.LogLevel != nil {
log.SetLogLevel(int(*config.LogLevel))
}
if config.Server.LogFile != "" {
log.Close()
log.OpenFile(config.Server.LogFile)
}

if config.Server.Address != "" {
tempSocketPath := c.getSocketPath(config.Server.Address)
Expand All @@ -84,12 +88,6 @@ func (c *Client) loadConfiguration(rawConfig []byte) bool {
}
c.setSocketPath(tempSocketPath)
}
if config.Server.LogFile != "" {
if err := log.OpenFile(config.Server.LogFile); err != nil {
log.Warning("Error opening log file: ", err)
}
}

if config.DefaultAction != "" {
clientDisconnectedRule.Action = rule.Action(config.DefaultAction)
clientErrorRule.Action = rule.Action(config.DefaultAction)
Expand Down

0 comments on commit aad69e9

Please sign in to comment.