Skip to content

Commit

Permalink
agents: fix synchronized code in GrpcAgent
Browse files Browse the repository at this point in the history
It should also cover the `start_profiling` fn execution.

PR-URL: #222
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
  • Loading branch information
santigimeno committed Nov 21, 2024
1 parent 39a6fb9 commit e958353
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions agents/grpc/src/grpc_agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1823,23 +1823,24 @@ ErrorType GrpcAgent::do_start_prof_init(
opt.metadata_pb = std::move(args.metadata());
}, options);

ErrorType error = (this->*start_profiling)(args, options);
if (error != ErrorType::ESuccess) {
return error;
}

nsuv::ns_mutex::scoped_lock lock(profile_state_lock_);
ProfileState& profile_state = profile_state_[type];
ProfileStor stor{ req.requestid(),
uv_now(&loop_),
nullptr,
std::move(options) };
options };
auto iter = profile_state.pending_profiles_map.emplace(thread_id,
std::move(stor));
if (iter.second == false) {
return ErrorType::EInProgressError;
}

ErrorType error = (this->*start_profiling)(args, options);
if (error != ErrorType::ESuccess) {
profile_state.pending_profiles_map.erase(iter.first);
return error;
}

if (type != kHeapSnapshot) {
profile_state.nr_profiles++;
}
Expand Down

0 comments on commit e958353

Please sign in to comment.