From 3ac75a0073bee60859475d3fa1f08e8edfe932ee Mon Sep 17 00:00:00 2001 From: Jacob Affinito Date: Thu, 2 Nov 2023 08:26:29 -0700 Subject: [PATCH] fix: Fix a segfault when using sendDataOnExit with Linux on Docker. (#2018) --- src/Agent/NewRelic/Agent/Core/AgentManager.cs | 1 + src/Agent/NewRelic/Agent/Core/Samplers/AbstractSampler.cs | 2 +- src/Agent/NewRelic/Agent/Core/Time/Scheduler.cs | 2 +- tests/Directory.Build.props | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Agent/NewRelic/Agent/Core/AgentManager.cs b/src/Agent/NewRelic/Agent/Core/AgentManager.cs index c42363611d..2b6c5fdb03 100644 --- a/src/Agent/NewRelic/Agent/Core/AgentManager.cs +++ b/src/Agent/NewRelic/Agent/Core/AgentManager.cs @@ -370,6 +370,7 @@ private void Shutdown(bool cleanShutdown) if (cleanShutdown) { + Log.Debug("Agent is connected, executing a clean shutdown."); EventBus.Publish(new PreCleanShutdownEvent()); EventBus.Publish(new CleanShutdownEvent()); } diff --git a/src/Agent/NewRelic/Agent/Core/Samplers/AbstractSampler.cs b/src/Agent/NewRelic/Agent/Core/Samplers/AbstractSampler.cs index e46a1c189c..1d050f48ea 100644 --- a/src/Agent/NewRelic/Agent/Core/Samplers/AbstractSampler.cs +++ b/src/Agent/NewRelic/Agent/Core/Samplers/AbstractSampler.cs @@ -18,7 +18,7 @@ protected virtual bool Enabled { get { - return !_configuration.DisableSamplers; + return !_configuration.DisableSamplers && !Agent.IsAgentShuttingDown; } } diff --git a/src/Agent/NewRelic/Agent/Core/Time/Scheduler.cs b/src/Agent/NewRelic/Agent/Core/Time/Scheduler.cs index 3ed0d62481..bf5e796aff 100644 --- a/src/Agent/NewRelic/Agent/Core/Time/Scheduler.cs +++ b/src/Agent/NewRelic/Agent/Core/Time/Scheduler.cs @@ -70,7 +70,7 @@ public void ExecuteEvery(Action action, TimeSpan timeBetweenExecutions, TimeSpan var existingTimer = _recurringTimers.GetValueOrDefault(action); if (existingTimer != null) { - Log.Debug("Stopping existing timer for scheduled action"); + Log.Debug("Stopping existing timer for scheduled action for " + action.Method.DeclaringType.FullName + "." + action.Method.Name); existingTimer.Dispose(); } diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props index 1f89c424d5..198a9cd3e2 100644 --- a/tests/Directory.Build.props +++ b/tests/Directory.Build.props @@ -4,5 +4,6 @@ true + false