Commit 80d0a7ab authored by Maged Michael's avatar Maged Michael Committed by Facebook Github Bot

hazptr: Add domain shutdown check in object retire

Summary: Add shutdown indicator to domain to be checked in retire to avoid accessing thread local private list of objects at shutdown time when the thread local structure may be already destroyed.

Reviewed By: djwatson

Differential Revision: D8501530

fbshipit-source-id: 16adef34f2fd265f35851c792bd9e62a2f19b81a
parent 59b63337
...@@ -55,6 +55,7 @@ class hazptr_domain { ...@@ -55,6 +55,7 @@ class hazptr_domain {
Atom<int> hcount_{0}; Atom<int> hcount_{0};
Atom<int> rcount_{0}; Atom<int> rcount_{0};
Atom<uint16_t> num_bulk_reclaims_{0}; Atom<uint16_t> num_bulk_reclaims_{0};
bool shutdown_{false};
public: public:
/** Constructor */ /** Constructor */
...@@ -62,6 +63,7 @@ class hazptr_domain { ...@@ -62,6 +63,7 @@ class hazptr_domain {
/** Destructor */ /** Destructor */
~hazptr_domain() { ~hazptr_domain() {
shutdown_ = true;
reclaim_all_objects(); reclaim_all_objects();
free_hazptr_recs(); free_hazptr_recs();
} }
...@@ -100,6 +102,7 @@ class hazptr_domain { ...@@ -100,6 +102,7 @@ class hazptr_domain {
hazptr_obj_list<Atom>&, hazptr_obj_list<Atom>&,
hazptr_domain<Atom>&) noexcept; hazptr_domain<Atom>&) noexcept;
friend class hazptr_holder<Atom>; friend class hazptr_holder<Atom>;
friend class hazptr_obj<Atom>;
#if FOLLY_HAZPTR_THR_LOCAL #if FOLLY_HAZPTR_THR_LOCAL
friend class hazptr_tc<Atom>; friend class hazptr_tc<Atom>;
#endif #endif
......
...@@ -108,7 +108,7 @@ class hazptr_obj { ...@@ -108,7 +108,7 @@ class hazptr_obj {
void push_to_retired(hazptr_domain<Atom>& domain) { void push_to_retired(hazptr_domain<Atom>& domain) {
#if FOLLY_HAZPTR_THR_LOCAL #if FOLLY_HAZPTR_THR_LOCAL
if (&domain == &default_hazptr_domain<Atom>()) { if (&domain == &default_hazptr_domain<Atom>() && !domain.shutdown_) {
hazptr_priv_tls<Atom>().push(this); hazptr_priv_tls<Atom>().push(this);
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment