From cc7b087fd4d1e515016b0db8310da960a1823608 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Thu, 27 Jun 2019 16:53:22 -0500 Subject: [PATCH 1/5] Update to thread-safe fc logging config and appbase with sighup handling on startup --- libraries/appbase | 2 +- libraries/fc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/appbase b/libraries/appbase index 74c282f41f4..bc9df062273 160000 --- a/libraries/appbase +++ b/libraries/appbase @@ -1 +1 @@ -Subproject commit 74c282f41f479d958c74c948b73cb128e5cf3614 +Subproject commit bc9df06227302394e52b25ea76b704945983f640 diff --git a/libraries/fc b/libraries/fc index 3a133c8d9ff..94260611488 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 3a133c8d9ff3cbf78fce43882cd7e1ff40d8c649 +Subproject commit 942606114880ec415f083fe1c7fe14f0e848158c From edb2d4533c2b126a940a53efb4cfebd7fb4876e1 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Thu, 27 Jun 2019 16:53:32 -0500 Subject: [PATCH 2/5] Use new fc::logger::update to update logger --- plugins/http_plugin/http_plugin.cpp | 8 +------- plugins/net_plugin/net_plugin.cpp | 7 +------ plugins/producer_plugin/producer_plugin.cpp | 15 ++------------- 3 files changed, 4 insertions(+), 26 deletions(-) diff --git a/plugins/http_plugin/http_plugin.cpp b/plugins/http_plugin/http_plugin.cpp index f8ed9178a67..6bb609c980c 100644 --- a/plugins/http_plugin/http_plugin.cpp +++ b/plugins/http_plugin/http_plugin.cpp @@ -29,10 +29,6 @@ #include #include -namespace fc { - extern std::unordered_map& get_logger_map(); -} - const fc::string logger_name("http_plugin"); fc::logger logger; @@ -637,9 +633,7 @@ namespace eosio { } void http_plugin::handle_sighup() { - if( fc::get_logger_map().find( logger_name ) != fc::get_logger_map().end() ) { - logger = fc::get_logger_map()[logger_name]; - } + fc::logger::update( logger_name, logger ); } void http_plugin::plugin_shutdown() { diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index fd9cdaba78d..9245c84a901 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -33,10 +33,6 @@ using namespace eosio::chain::plugin_interface; -namespace fc { - extern std::unordered_map& get_logger_map(); -} - namespace eosio { static appbase::abstract_plugin& _net_plugin = app().register_plugin(); @@ -3341,8 +3337,7 @@ namespace eosio { } void net_plugin::handle_sighup() { - if(fc::get_logger_map().find(logger_name) != fc::get_logger_map().end()) - logger = fc::get_logger_map()[logger_name]; + fc::logger::update( logger_name, logger ); } void net_plugin::plugin_shutdown() { diff --git a/plugins/producer_plugin/producer_plugin.cpp b/plugins/producer_plugin/producer_plugin.cpp index 33166a9c5cb..a3a3ca408ff 100644 --- a/plugins/producer_plugin/producer_plugin.cpp +++ b/plugins/producer_plugin/producer_plugin.cpp @@ -43,12 +43,6 @@ using std::vector; using std::deque; using boost::signals2::scoped_connection; -// HACK TO EXPOSE LOGGER MAP - -namespace fc { - extern std::unordered_map& get_logger_map(); -} - const fc::string logger_name("producer_plugin"); fc::logger _log; @@ -912,13 +906,8 @@ void producer_plugin::plugin_shutdown() { } void producer_plugin::handle_sighup() { - auto& logger_map = fc::get_logger_map(); - if(logger_map.find(logger_name) != logger_map.end()) { - _log = logger_map[logger_name]; - } - if( logger_map.find(trx_trace_logger_name) != logger_map.end()) { - _trx_trace_log = logger_map[trx_trace_logger_name]; - } + fc::logger::update( logger_name, _log ); + fc::logger::update( trx_trace_logger_name, _trx_trace_log ); } void producer_plugin::pause() { From c075ffc3aee5d1cb4a801ffce9b776da738c5ac5 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Thu, 27 Jun 2019 16:53:46 -0500 Subject: [PATCH 3/5] Call new fc::log_config::initialize_appenders --- programs/nodeos/main.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/programs/nodeos/main.cpp b/programs/nodeos/main.cpp index a0cd7bd8682..4c7478f3a70 100644 --- a/programs/nodeos/main.cpp +++ b/programs/nodeos/main.cpp @@ -21,10 +21,6 @@ using namespace appbase; using namespace eosio; -namespace fc { - std::unordered_map& get_appender_map(); -} - namespace detail { void configure_logging(const bfs::path& config_path) @@ -51,12 +47,11 @@ void configure_logging(const bfs::path& config_path) void logging_conf_handler() { - ilog("Received HUP. Reloading logging configuration."); auto config_path = app().get_logging_conf(); + ilog("Received HUP. Reloading logging configuration from ${p}.", ("p", config_path.string())); if(fc::exists(config_path)) ::detail::configure_logging(config_path); - for(auto iter : fc::get_appender_map()) - iter.second->initialize(app().get_io_service()); + fc::log_config::initialize_appenders( app().get_io_service() ); } void initialize_logging() @@ -64,8 +59,7 @@ void initialize_logging() auto config_path = app().get_logging_conf(); if(fc::exists(config_path)) fc::configure_logging(config_path); // intentionally allowing exceptions to escape - for(auto iter : fc::get_appender_map()) - iter.second->initialize(app().get_io_service()); + fc::log_config::initialize_appenders( app().get_io_service() ); app().set_sighup_callback(logging_conf_handler); } From 9e70ca39e4fac7e2f03b3bf882a23e9266849d3a Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Thu, 27 Jun 2019 21:29:26 -0500 Subject: [PATCH 4/5] Update to appbase with peer review fixes --- libraries/appbase | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/appbase b/libraries/appbase index bc9df062273..adbb8695d33 160000 --- a/libraries/appbase +++ b/libraries/appbase @@ -1 +1 @@ -Subproject commit bc9df06227302394e52b25ea76b704945983f640 +Subproject commit adbb8695d33b848a7431d4121120b57ce1eac2e3 From 26f1ffc29b3206672c14cf4a69d7edfb80353905 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Thu, 27 Jun 2019 22:11:08 -0500 Subject: [PATCH 5/5] Update to fc and appbase tips --- libraries/appbase | 2 +- libraries/fc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/appbase b/libraries/appbase index adbb8695d33..4b95cd33659 160000 --- a/libraries/appbase +++ b/libraries/appbase @@ -1 +1 @@ -Subproject commit adbb8695d33b848a7431d4121120b57ce1eac2e3 +Subproject commit 4b95cd33659e18bd4f6ea2327202cfa20b09c658 diff --git a/libraries/fc b/libraries/fc index 94260611488..78eaa36e930 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 942606114880ec415f083fe1c7fe14f0e848158c +Subproject commit 78eaa36e93094b3daabdba291745c38cb549bc0d