Skip to content

Commit

Permalink
Merge pull request #2038 from AntelopeIO/prom_handler_fix_50
Browse files Browse the repository at this point in the history
[5.0] only register prometheus handlers when `prometheus_plugin` enabled; fixing memory leak
  • Loading branch information
spoonincode authored Jan 4, 2024
2 parents e2fda3b + 3cbf05f commit 31f7bc4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
1 change: 0 additions & 1 deletion plugins/net_plugin/net_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4597,7 +4597,6 @@ namespace eosio {
// called from any thread
void connections_manager::start_conn_timers() {
start_conn_timer(connector_period, {}, timer_type::check); // this locks mutex
start_conn_timer(connector_period, {}, timer_type::stats); // this locks mutex
if (update_p2p_connection_metrics) {
start_conn_timer(connector_period + connector_period / 2, {}, timer_type::stats); // this locks mutex
}
Expand Down
9 changes: 3 additions & 6 deletions plugins/prometheus_plugin/prometheus_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,13 @@ namespace eosio {
struct prometheus_plugin_impl {

eosio::chain::named_thread_pool<struct prom> _prometheus_thread_pool;
boost::asio::io_context::strand _prometheus_strand;
boost::asio::io_context::strand _prometheus_strand{_prometheus_thread_pool.get_executor()};
metrics::catalog_type _catalog;
fc::microseconds _max_response_time_us;

prometheus_plugin_impl(): _prometheus_strand(_prometheus_thread_pool.get_executor()){
_catalog.register_update_handlers(_prometheus_strand);
}
};

prometheus_plugin::prometheus_plugin()
: my(new prometheus_plugin_impl{}) {
: my(new prometheus_plugin_impl) {
}

prometheus_plugin::~prometheus_plugin() = default;
Expand All @@ -53,6 +49,7 @@ namespace eosio {


void prometheus_plugin::plugin_initialize(const variables_map& options) {
my->_catalog.register_update_handlers(my->_prometheus_strand);

auto& _http_plugin = app().get_plugin<http_plugin>();
my->_max_response_time_us = _http_plugin.get_max_response_time();
Expand Down

0 comments on commit 31f7bc4

Please sign in to comment.