Shared/Metric: Fix crash on shutdown

Fix crash on shutdown with metrics enabled but InfluxDB stopping before worldserver
This commit is contained in:
jackpoz authored and Aokromes committed 2017-12-17 15:37:30 +01:00
1 parent 9c3752c8f2
commit 4283252731
3 files changed
+6 -5

No files matched your search

+4 -3
View File
@@ -208,16 +208,17 @@ void Metric::ScheduleSend()
}
}
void Metric::ForceSend()
void Metric::Unload()
{
// Send what's queued only if io_service is stopped (so only on shutdown)
if (_enabled && _batchTimer->get_io_service().stopped())
{
_enabled = false;
SendBatch();
_batchTimer->cancel();
_overallStatusTimer->cancel();
}
_batchTimer->cancel();
_overallStatusTimer->cancel();
}
void Metric::ScheduleOverallStatusLog()
+1 -1
View File
@@ -110,7 +110,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; }
};
+1 -1
View File
@@ -232,7 +232,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);