From 050ed9e61e9d20531700435adc72ee15efa26c7b Mon Sep 17 00:00:00 2001 From: Steven Soroka Date: Tue, 21 Apr 2020 13:33:47 -0400 Subject: [PATCH] fix issue with closing flush signal channel (#7384) --- agent/agent.go | 1 + agent/{agent_notwindows.go => agent_posix.go} | 3 +++ agent/agent_windows.go | 6 +++++- 3 files changed, 9 insertions(+), 1 deletion(-) rename agent/{agent_notwindows.go => agent_posix.go} (78%) diff --git a/agent/agent.go b/agent/agent.go index 97c6b01c8..863309f28 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -556,6 +556,7 @@ func (a *Agent) flushLoop( // watch for flush requests flushRequested := make(chan os.Signal, 1) watchForFlushSignal(flushRequested) + defer stopListeningForFlushSignal(flushRequested) // align to round interval if a.Config.Agent.RoundInterval { diff --git a/agent/agent_notwindows.go b/agent/agent_posix.go similarity index 78% rename from agent/agent_notwindows.go rename to agent/agent_posix.go index 4d1f496a9..09552cac0 100644 --- a/agent/agent_notwindows.go +++ b/agent/agent_posix.go @@ -12,5 +12,8 @@ const flushSignal = syscall.SIGUSR1 func watchForFlushSignal(flushRequested chan os.Signal) { signal.Notify(flushRequested, flushSignal) +} + +func stopListeningForFlushSignal(flushRequested chan os.Signal) { defer signal.Stop(flushRequested) } diff --git a/agent/agent_windows.go b/agent/agent_windows.go index 7e7a0cabd..94ed9d006 100644 --- a/agent/agent_windows.go +++ b/agent/agent_windows.go @@ -5,5 +5,9 @@ package agent import "os" func watchForFlushSignal(flushRequested chan os.Signal) { - // not implemented + // not supported +} + +func stopListeningForFlushSignal(flushRequested chan os.Signal) { + // not supported }