From cddaec7c7921cc2230eaf701f28185cfebdef76d Mon Sep 17 00:00:00 2001 From: Zhang Yifan Date: Fri, 22 Jan 2021 08:52:53 +0800 Subject: [PATCH] fix: fix the usage of service_engine::get_all_nodes() (#730) --- src/replica/storage/simple_kv/test/checker.cpp | 4 ++-- src/runtime/service_api_c.cpp | 6 +++--- src/runtime/tool_api.cpp | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/replica/storage/simple_kv/test/checker.cpp b/src/replica/storage/simple_kv/test/checker.cpp index bb9d7a9e7b..4fc5c05194 100644 --- a/src/replica/storage/simple_kv/test/checker.cpp +++ b/src/replica/storage/simple_kv/test/checker.cpp @@ -173,8 +173,8 @@ bool test_checker::init(const std::string &name, const std::vectorid(); std::string name = node.second->full_name(); rpc_address paddr = node.second->rpc()->primary_address(); diff --git a/src/runtime/service_api_c.cpp b/src/runtime/service_api_c.cpp index 5646a3daff..dbc4c32b7a 100644 --- a/src/runtime/service_api_c.cpp +++ b/src/runtime/service_api_c.cpp @@ -208,8 +208,8 @@ DSN_API bool dsn_mimic_app(const char *app_role, int index) } } - auto nodes = ::dsn::service_engine::instance().get_all_nodes(); - for (auto &n : nodes) { + const auto &nodes = dsn::service_engine::instance().get_all_nodes(); + for (const auto &n : nodes) { if (n.second->spec().role_name == std::string(app_role) && n.second->spec().index == index) { ::dsn::task::set_tls_dsn_context(n.second.get(), nullptr); @@ -508,7 +508,7 @@ bool run(const char *config_file, } } - if (::dsn::service_engine::instance().get_all_nodes().size() == 0) { + if (dsn::service_engine::instance().get_all_nodes().size() == 0) { printf("no app are created, usually because \n" "app_name is not specified correctly, should be 'xxx' in [apps.xxx]\n" "or app_index (1-based) is greater than specified count in config file\n"); diff --git a/src/runtime/tool_api.cpp b/src/runtime/tool_api.cpp index 0eab6cf3eb..0e157e2bd7 100644 --- a/src/runtime/tool_api.cpp +++ b/src/runtime/tool_api.cpp @@ -80,8 +80,8 @@ tool_app::tool_app(const char *name) : tool_base(name) {} void tool_app::start_all_apps() { - auto apps = service_engine::instance().get_all_nodes(); - for (auto &kv : apps) { + const auto &apps = service_engine::instance().get_all_nodes(); + for (const auto &kv : apps) { task *t = new service_control_task(kv.second.get(), true); t->set_delay(1000 * kv.second.get()->spec().delay_seconds); t->enqueue(); @@ -90,8 +90,8 @@ void tool_app::start_all_apps() void tool_app::stop_all_apps(bool cleanup) { - auto apps = service_engine::instance().get_all_nodes(); - for (auto &kv : apps) { + const auto &apps = service_engine::instance().get_all_nodes(); + for (const auto &kv : apps) { task *t = new service_control_task(kv.second.get(), false, cleanup); t->enqueue(); }