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

Commit

Permalink
fix(perf_counter_wrapper): avoid using invalid perf_counters::instanc…
Browse files Browse the repository at this point in the history
…e() to remove counter (#750)
  • Loading branch information
zhangyifan27 authored Feb 18, 2021
1 parent a057ce5 commit 6d13c07
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
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

0 comments on commit 6d13c07

Please sign in to comment.