Commit 360bc186 authored by Alexander Zhavnerchik's avatar Alexander Zhavnerchik Committed by Facebook Github Bot

Remove Indestructible from folly::setting::SettingCore class member

Summary:
Having Indestructible field in SettingsCore makes it leak memory when
threads die.

Reviewed By: yfeldblum

Differential Revision: D10118572

fbshipit-source-id: 68696983128049525018a911b03cb7ea8add53ab
parent 25d70b2c
......@@ -340,8 +340,7 @@ class SettingCore : public SettingCoreBase {
trivialStorage_(trivialStorage),
localValue_([]() {
return new CachelinePadded<
Indestructible<std::pair<Version, std::shared_ptr<Contents>>>>(
0, nullptr);
std::pair<Version, std::shared_ptr<Contents>>>(0, nullptr);
}) {
set(defaultValue_, "default");
registerSetting(*this);
......@@ -360,19 +359,18 @@ class SettingCore : public SettingCoreBase {
*/
CachelinePadded<std::atomic<Version>> settingVersion_{1};
ThreadLocal<CachelinePadded<
Indestructible<std::pair<Version, std::shared_ptr<Contents>>>>>
ThreadLocal<CachelinePadded<std::pair<Version, std::shared_ptr<Contents>>>>
localValue_;
FOLLY_ALWAYS_INLINE std::shared_ptr<Contents>& tlValue() const {
auto& value = ***localValue_;
FOLLY_ALWAYS_INLINE const std::shared_ptr<Contents>& tlValue() const {
auto& value = **localValue_;
if (LIKELY(value.first == *settingVersion_)) {
return value.second;
}
return tlValueSlow();
}
FOLLY_NOINLINE std::shared_ptr<Contents>& tlValueSlow() const {
auto& value = ***localValue_;
FOLLY_NOINLINE const std::shared_ptr<Contents>& tlValueSlow() const {
auto& value = **localValue_;
while (value.first < *settingVersion_) {
/* If this destroys the old value, do it without holding the lock */
value.second.reset();
......
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