diff options
author | Max Kellermann <max.kellermann@ionos.com> | 2024-10-09 23:21:11 +0200 |
---|---|---|
committer | Max Kellermann <max.kellermann@ionos.com> | 2024-10-11 12:26:37 +0200 |
commit | 5b0d849730ce20d68ffafcb612c5f6fc8b87dd9a (patch) | |
tree | f71e8c7e0fdd3aba0989d1ca99fd03b68a637ecd /src | |
parent | Merge pull request #59720 from myoungwon/wip-fix-overlapped-write (diff) | |
download | ceph-5b0d849730ce20d68ffafcb612c5f6fc8b87dd9a.tar.xz ceph-5b0d849730ce20d68ffafcb612c5f6fc8b87dd9a.zip |
common/ceph_context: use std::atomic<std::shared_ptr<T>>
Fixes the compiler warning:
src/common/ceph_context.h: In member function ‘std::shared_ptr<std::vector<entity_addrvec_t> > ceph::common::CephContext::get_mon_addrs() const’:
src/common/ceph_context.h:288:36: warning: ‘std::shared_ptr<_Tp> std::atomic_load_explicit(const shared_ptr<_Tp>*, memory_order) [with _Tp = vector<entity_addrvec_t>]’ is deprecated: use 'std::atomic<std::shared_ptr<T>>' instead [-Wdeprecated-declarations]
288 | auto ptr = atomic_load_explicit(&_mon_addrs, std::memory_order_relaxed);
| ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/shared_ptr_atomic.h:133:5: note: declared here
133 | atomic_load_explicit(const shared_ptr<_Tp>* __p, memory_order)
| ^~~~~~~~~~~~~~~~~~~~
The modernized version does not build with GCC 11, so this patch
contains both versions for now, switched by a `__GNUC__` preprocessor
check.
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/common/ceph_context.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/common/ceph_context.h b/src/common/ceph_context.h index f1877647877..6a02d5c5bf1 100644 --- a/src/common/ceph_context.h +++ b/src/common/ceph_context.h @@ -282,10 +282,20 @@ public: void set_mon_addrs(const MonMap& mm); void set_mon_addrs(const std::vector<entity_addrvec_t>& in) { auto ptr = std::make_shared<std::vector<entity_addrvec_t>>(in); +#if defined(__GNUC__) && __GNUC__ < 12 + // workaround for GCC 11 bug atomic_store_explicit(&_mon_addrs, std::move(ptr), std::memory_order_relaxed); +#else + _mon_addrs.store(std::move(ptr), std::memory_order_relaxed); +#endif } std::shared_ptr<std::vector<entity_addrvec_t>> get_mon_addrs() const { +#if defined(__GNUC__) && __GNUC__ < 12 + // workaround for GCC 11 bug auto ptr = atomic_load_explicit(&_mon_addrs, std::memory_order_relaxed); +#else + auto ptr = _mon_addrs.load(std::memory_order_relaxed); +#endif return ptr; } @@ -306,7 +316,12 @@ private: int _crypto_inited; +#if defined(__GNUC__) && __GNUC__ < 12 + // workaround for GCC 11 bug std::shared_ptr<std::vector<entity_addrvec_t>> _mon_addrs; +#else + std::atomic<std::shared_ptr<std::vector<entity_addrvec_t>>> _mon_addrs; +#endif /* libcommon service thread. * SIGHUP wakes this thread, which then reopens logfiles */ |