Skip to content

Commit

Permalink
fix: fix the usage of service_engine::get_all_nodes() (#730)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyifan27 authored Jan 22, 2021
1 parent 5c8de19 commit cddaec7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/replica/storage/simple_kv/test/checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ bool test_checker::init(const std::string &name, const std::vector<service_app *
}
}

auto nodes = ::dsn::service_engine::instance().get_all_nodes();
for (auto &node : nodes) {
const auto &nodes = dsn::service_engine::instance().get_all_nodes();
for (const auto &node : nodes) {
int id = node.second->id();
std::string name = node.second->full_name();
rpc_address paddr = node.second->rpc()->primary_address();
Expand Down
6 changes: 3 additions & 3 deletions src/runtime/service_api_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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");
Expand Down
8 changes: 4 additions & 4 deletions src/runtime/tool_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
}
Expand Down

0 comments on commit cddaec7

Please sign in to comment.