From 01efa15b849ba08fd1b651038fadaab2ee82a323 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Thu, 3 Jul 2025 15:07:25 -0400 Subject: [PATCH] MT#63171 Statistics: add dtor This module initialises and starts the StatsUDPServer. Stop its worker when the module is destroyed. Change-Id: I265d7ee103866a5946b066e4e7d42376e3510cac (cherry picked from commit 4bd36ffc89927c5e6af8cc49bc466744909252a9) --- core/plug-in/stats/Statistics.cpp | 9 +++++++++ core/plug-in/stats/Statistics.h | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/core/plug-in/stats/Statistics.cpp b/core/plug-in/stats/Statistics.cpp index 5a3cefd8..f4a80183 100644 --- a/core/plug-in/stats/Statistics.cpp +++ b/core/plug-in/stats/Statistics.cpp @@ -36,6 +36,15 @@ StatsFactory::StatsFactory(const std::string& _app_name) { } +StatsFactory::~StatsFactory() +{ + StatsUDPServer* stat_srv = StatsUDPServer::instance(); + if (stat_srv) { + stat_srv->stop(); + stat_srv->join(); + } +} + int StatsFactory::onLoad() { StatsUDPServer* stat_srv = StatsUDPServer::instance(); diff --git a/core/plug-in/stats/Statistics.h b/core/plug-in/stats/Statistics.h index 8803e85e..f8c7dbd4 100644 --- a/core/plug-in/stats/Statistics.h +++ b/core/plug-in/stats/Statistics.h @@ -35,7 +35,8 @@ class StatsFactory: public AmPluginFactory { public: StatsFactory(const std::string& _app_name); - + ~StatsFactory(); + // AmPluginFactory interface int onLoad(); };