aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjackpoz <giacomopoz@gmail.com>2017-12-17 14:35:18 +0100
committerfunjoker <funjoker109@gmail.com>2021-03-15 20:17:31 +0100
commit8313053a3bbf8950daf3a1c134dde8a25edf0bd2 (patch)
treeb51d8a9ce3f663fd57421fbd5d5694587a0c560a /src
parent7bd3914663735fc0744a97b81140adef8b4d276b (diff)
Shared/Metric: Fix crash on shutdown
Fix crash on shutdown with metrics enabled but InfluxDB stopping before worldserver (cherry picked from commit 45b2bcfaf266cac74806ed71f32b8dc02cd2321e)
Diffstat (limited to 'src')
-rw-r--r--src/common/Metric/Metric.cpp7
-rw-r--r--src/common/Metric/Metric.h2
-rw-r--r--src/server/worldserver/Main.cpp2
3 files changed, 6 insertions, 5 deletions
diff --git a/src/common/Metric/Metric.cpp b/src/common/Metric/Metric.cpp
index 45893fc1b14..f14d3fac531 100644
--- a/src/common/Metric/Metric.cpp
+++ b/src/common/Metric/Metric.cpp
@@ -213,16 +213,17 @@ void Metric::ScheduleSend()
}
}
-void Metric::ForceSend()
+void Metric::Unload()
{
// Send what's queued only if IoContext is stopped (so only on shutdown)
if (_enabled && Trinity::Asio::get_io_context(*_batchTimer).stopped())
{
_enabled = false;
SendBatch();
- _batchTimer->cancel();
- _overallStatusTimer->cancel();
}
+
+ _batchTimer->cancel();
+ _overallStatusTimer->cancel();
}
void Metric::ScheduleOverallStatusLog()
diff --git a/src/common/Metric/Metric.h b/src/common/Metric/Metric.h
index d5085d27307..1ce27649fd9 100644
--- a/src/common/Metric/Metric.h
+++ b/src/common/Metric/Metric.h
@@ -115,7 +115,7 @@ public:
void LogEvent(std::string const& category, std::string const& title, std::string const& description);
- void ForceSend();
+ void Unload();
bool IsEnabled() const { return _enabled; }
};
diff --git a/src/server/worldserver/Main.cpp b/src/server/worldserver/Main.cpp
index e9b9e1aff8d..aea48b8ce93 100644
--- a/src/server/worldserver/Main.cpp
+++ b/src/server/worldserver/Main.cpp
@@ -243,7 +243,7 @@ extern int main(int argc, char** argv)
std::shared_ptr<void> sMetricHandle(nullptr, [](void*)
{
TC_METRIC_EVENT("events", "Worldserver shutdown", "");
- sMetric->ForceSend();
+ sMetric->Unload();
});
sScriptMgr->SetScriptLoader(AddScripts);