Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

fix(perf_counter_wrapper): avoid using invalid perf_counters::instance() to remove counter #750

Merged
merged 1 commit into from
Feb 18, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/dsn/perf_counter/perf_counter_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class perf_counter_wrapper
perf_counter_wrapper &operator=(perf_counter_wrapper &other) = delete;
perf_counter_wrapper &operator=(perf_counter_wrapper &&other) = delete;

~perf_counter_wrapper() { clear(); }
~perf_counter_wrapper() {}

// clear the real perf-counter object.
// call this function if you want free the counter before the wrapper's destructor is called
Expand Down Expand Up @@ -103,6 +103,7 @@ class perf_counter_wrapper

dsn::perf_counter *get() const { return _counter; }
dsn::perf_counter *operator->() const { return _counter; }

private:
// use raw pointer to make the class object small, so it can be accessed quickly
dsn::perf_counter *_counter;
Expand Down
1 change: 1 addition & 0 deletions src/perf_counter/perf_counters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ perf_counters::perf_counters()

perf_counters::~perf_counters()
{
_counters.clear();
UNREGISTER_VALID_HANDLER(_perf_counters_cmd);
UNREGISTER_VALID_HANDLER(_perf_counters_by_substr_cmd);
UNREGISTER_VALID_HANDLER(_perf_counters_by_prefix_cmd);
Expand Down