Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mgr: fix py calls for dne service perf counters #17605

Merged
merged 1 commit into from Sep 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/mgr/DaemonState.cc
Expand Up @@ -85,7 +85,12 @@ DaemonStatePtr DaemonStateIndex::get(const DaemonKey &key)
{
Mutex::Locker l(lock);

return all.at(key);
auto iter = all.find(key);
if (iter != all.end()) {
return iter->second;
} else {
return nullptr;
}
}

void DaemonStateIndex::cull(const std::string& svc_name,
Expand Down
8 changes: 4 additions & 4 deletions src/mgr/PyModules.cc
Expand Up @@ -679,9 +679,8 @@ PyObject* PyModules::get_counter_python(
f.open_array_section(path.c_str());

auto metadata = daemon_state.get(DaemonKey(svc_name, svc_id));

Mutex::Locker l2(metadata->lock);
if (metadata) {
Mutex::Locker l2(metadata->lock);
if (metadata->perf_counters.instances.count(path)) {
auto counter_instance = metadata->perf_counters.instances.at(path);
const auto &data = counter_instance.get_data();
Expand Down Expand Up @@ -726,8 +725,9 @@ PyObject* PyModules::get_perf_schema_python(
} else {
auto key = DaemonKey(svc_type, svc_id);
// so that the below can be a loop in all cases
if (daemon_state.exists(key)) {
states[key] = daemon_state.get(key);
auto got = daemon_state.get(key);
if (got != nullptr) {
states[key] = got;
}
}

Expand Down