summaryrefslogtreecommitdiff
path: root/absl/container/internal/hashtablez_sampler.cc
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2021-12-01 15:08:07 -0800
committerGravatar Andy Getz <durandal@google.com>2021-12-02 14:11:24 -0500
commite11e039e02ef30a98a7928ce6c59cebe096dd753 (patch)
tree40e34c4abd819883b86b423ebe5ef77b960e82af /absl/container/internal/hashtablez_sampler.cc
parentcad715dbf375a336fcb0b2b0ef57fc2b7a1b0b4b (diff)
Export of internal Abseil changes
-- 08d99ee216b7bfac1c5182db952d4e053e5ebc31 by Abseil Team <absl-team@google.com>: Fix race condition reported by tsan on `inline_element_size` in hashtablez. PiperOrigin-RevId: 413520771 GitOrigin-RevId: 08d99ee216b7bfac1c5182db952d4e053e5ebc31 Change-Id: Ibd396803f04a659cfbdb8dc7ec37511643657694
Diffstat (limited to 'absl/container/internal/hashtablez_sampler.cc')
-rw-r--r--absl/container/internal/hashtablez_sampler.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/absl/container/internal/hashtablez_sampler.cc b/absl/container/internal/hashtablez_sampler.cc
index 1a3ca7cc..a3e15a70 100644
--- a/absl/container/internal/hashtablez_sampler.cc
+++ b/absl/container/internal/hashtablez_sampler.cc
@@ -111,7 +111,8 @@ HashtablezInfo* SampleSlow(int64_t* next_sample, size_t inline_element_size) {
if (ABSL_PREDICT_FALSE(ShouldForceSampling())) {
*next_sample = 1;
HashtablezInfo* result = GlobalHashtablezSampler().Register();
- result->inline_element_size = inline_element_size;
+ result->inline_element_size.store(inline_element_size,
+ std::memory_order_relaxed);
return result;
}
@@ -138,7 +139,8 @@ HashtablezInfo* SampleSlow(int64_t* next_sample, size_t inline_element_size) {
}
HashtablezInfo* result = GlobalHashtablezSampler().Register();
- result->inline_element_size = inline_element_size;
+ result->inline_element_size.store(inline_element_size,
+ std::memory_order_relaxed);
return result;
#endif
}