Skip to content

Commit

Permalink
Fix polling issue after connection closed
Browse files Browse the repository at this point in the history
  • Loading branch information
deven96 committed Nov 5, 2022
1 parent 2614b4b commit d734b69
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions client/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ func (hosts *HostsController) sendMetric(host config.Host, client *Client) {
},
Error: false,
}
client.Send <- message
if config.Contains(hosts.ReadOnlyHosts, host) {
client.Send <- message
}
} else {
// check for error 127 which means command was not found
var errorContent string
Expand All @@ -112,7 +114,10 @@ func (hosts *HostsController) sendMetric(host config.Host, client *Client) {
func (hosts *HostsController) Poll(client *Client) {
for {
for _, host := range hosts.Info.Hosts {
if config.Contains(hosts.ReadOnlyHosts, host) && hosts.clientConnected() {
if !hosts.clientConnected() {
return
}
if config.Contains(hosts.ReadOnlyHosts, host) {
go hosts.sendMetric(host, client)
}
}
Expand Down

0 comments on commit d734b69

Please sign in to comment.