Commit 4bfcf7b4 authored by Maged Michael's avatar Maged Michael Committed by Facebook Github Bot

hazptr: Prevent destructor of hazptr_priv from getting reference to itself

Summary: Prevent destructor of hazptr_priv which is a SingltonThreadLocal from making call to get a reference to the singlton. This may be a problem on some platforms.

Reviewed By: djwatson

Differential Revision: D8711918

fbshipit-source-id: fb319f640cff74e46ce27ab28ae5fbf93961b262
parent fb02412a
......@@ -127,6 +127,7 @@ hazptr_domain<Atom>& default_hazptr_domain();
template <template <typename> class Atom = std::atomic>
void hazptr_domain_push_retired(
hazptr_obj_list<Atom>& l,
bool check = true,
hazptr_domain<Atom>& domain = default_hazptr_domain<Atom>()) noexcept;
/** hazptr_retire */
......
......@@ -100,6 +100,7 @@ class hazptr_domain {
private:
friend void hazptr_domain_push_retired<Atom>(
hazptr_obj_list<Atom>&,
bool check,
hazptr_domain<Atom>&) noexcept;
friend class hazptr_holder<Atom>;
friend class hazptr_obj<Atom>;
......@@ -359,8 +360,9 @@ FOLLY_ALWAYS_INLINE hazptr_domain<Atom>& default_hazptr_domain() {
template <template <typename> class Atom>
void hazptr_domain_push_retired(
hazptr_obj_list<Atom>& l,
bool check,
hazptr_domain<Atom>& domain) noexcept {
domain.push_retired(l);
domain.push_retired(l, check);
}
/** hazptr_retire */
......
......@@ -114,7 +114,7 @@ class hazptr_obj {
}
#endif
hazptr_obj_list<Atom> l(this);
hazptr_domain_push_retired(l, domain);
hazptr_domain_push_retired(l, true, domain);
}
FOLLY_NOINLINE void pre_retire_check_fail() noexcept {
......
......@@ -187,12 +187,8 @@ class hazptr_priv {
}
void push(hazptr_obj<Atom>* obj) {
if (!in_dtor_) {
DCHECK(!in_dtor_);
push_in_priv_list(obj);
} else {
hazptr_obj_list<Atom> l(obj);
hazptr_domain_push_retired<Atom>(l);
}
}
void push_in_priv_list(hazptr_obj<Atom>* obj) {
......@@ -219,7 +215,7 @@ class hazptr_priv {
if (h) {
DCHECK(t);
hazptr_obj_list<Atom> l(h, t, rcount_);
hazptr_domain_push_retired<Atom>(l);
hazptr_domain_push_retired<Atom>(l, false);
rcount_ = 0;
}
}
......
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