Skip to content

Commit b2b211e

Browse files
authored
Merge pull request ceph#60225 from MaxKellermann/ceph_context_atomic
common/ceph_context: use std::atomic<std::shared_ptr<T>> Reviewed-by: Casey Bodley <[email protected]>
2 parents 34556a1 + 5b0d849 commit b2b211e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/common/ceph_context.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,20 @@ class CephContext {
282282
void set_mon_addrs(const MonMap& mm);
283283
void set_mon_addrs(const std::vector<entity_addrvec_t>& in) {
284284
auto ptr = std::make_shared<std::vector<entity_addrvec_t>>(in);
285+
#if defined(__GNUC__) && __GNUC__ < 12
286+
// workaround for GCC 11 bug
285287
atomic_store_explicit(&_mon_addrs, std::move(ptr), std::memory_order_relaxed);
288+
#else
289+
_mon_addrs.store(std::move(ptr), std::memory_order_relaxed);
290+
#endif
286291
}
287292
std::shared_ptr<std::vector<entity_addrvec_t>> get_mon_addrs() const {
293+
#if defined(__GNUC__) && __GNUC__ < 12
294+
// workaround for GCC 11 bug
288295
auto ptr = atomic_load_explicit(&_mon_addrs, std::memory_order_relaxed);
296+
#else
297+
auto ptr = _mon_addrs.load(std::memory_order_relaxed);
298+
#endif
289299
return ptr;
290300
}
291301

@@ -306,7 +316,12 @@ class CephContext {
306316

307317
int _crypto_inited;
308318

319+
#if defined(__GNUC__) && __GNUC__ < 12
320+
// workaround for GCC 11 bug
309321
std::shared_ptr<std::vector<entity_addrvec_t>> _mon_addrs;
322+
#else
323+
std::atomic<std::shared_ptr<std::vector<entity_addrvec_t>>> _mon_addrs;
324+
#endif
310325

311326
/* libcommon service thread.
312327
* SIGHUP wakes this thread, which then reopens logfiles */

0 commit comments

Comments
 (0)