50
50
#include " dcp/producer.h"
51
51
#include " warmup.h"
52
52
53
- static ALLOCATOR_HOOKS_API * hooksApi;
54
- static SERVER_LOG_API * loggerApi;
53
+ static AtomicValue< ALLOCATOR_HOOKS_API*> hooksApi;
54
+ static AtomicValue< SERVER_LOG_API*> loggerApi;
55
55
56
56
static size_t percentOf (size_t val, double percent) {
57
57
return static_cast <size_t >(static_cast <double >(val) * percent);
@@ -1805,8 +1805,8 @@ extern "C" {
1805
1805
return ENGINE_ENOTSUP;
1806
1806
}
1807
1807
1808
- hooksApi = api->alloc_hooks ;
1809
- loggerApi = api->log ;
1808
+ hooksApi. store ( api->alloc_hooks , std::memory_order_relaxed) ;
1809
+ loggerApi. store ( api->log , std::memory_order_relaxed) ;
1810
1810
MemoryTracker::getInstance ();
1811
1811
ObjectRegistry::initialize (api->alloc_hooks ->get_allocation_size );
1812
1812
@@ -1913,18 +1913,18 @@ extern "C" {
1913
1913
void LOG (EXTENSION_LOG_LEVEL severity, const char *fmt, ...) {
1914
1914
char buffer[2048 ];
1915
1915
1916
- if (loggerApi != nullptr ) {
1916
+ if (loggerApi. load (std::memory_order_relaxed) != nullptr ) {
1917
1917
static EXTENSION_LOGGER_DESCRIPTOR* logger;
1918
1918
if (logger == nullptr ) {
1919
1919
// This locking isn't really needed because get_logger will
1920
1920
// always return the same address, but it'll keep thread sanitizer
1921
1921
// and other tools from complaining ;-)
1922
1922
static std::mutex mutex;
1923
1923
std::lock_guard<std::mutex> guard (mutex);
1924
- logger = loggerApi->get_logger ();
1924
+ logger = loggerApi. load (std::memory_order_relaxed) ->get_logger ();
1925
1925
}
1926
1926
1927
- if (loggerApi->get_level () <= severity) {
1927
+ if (loggerApi. load (std::memory_order_relaxed) ->get_level () <= severity) {
1928
1928
EventuallyPersistentEngine *engine = ObjectRegistry::onSwitchThread (NULL , true );
1929
1929
va_list va;
1930
1930
va_start (va, fmt);
@@ -1942,7 +1942,7 @@ void LOG(EXTENSION_LOG_LEVEL severity, const char *fmt, ...) {
1942
1942
}
1943
1943
1944
1944
ALLOCATOR_HOOKS_API *getHooksApi (void ) {
1945
- return hooksApi;
1945
+ return hooksApi. load (std::memory_order_relaxed) ;
1946
1946
}
1947
1947
1948
1948
EventuallyPersistentEngine::EventuallyPersistentEngine (
0 commit comments