From 538c7fdf2a9b8ad75cfad9cd45f04c77e70369ef Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Tue, 7 Apr 2015 17:28:37 +0300 Subject: [PATCH] cql3: fix query_options::DEFAULT not smp safe Contains a shared_ptr (inside specific_options), so cannot be global. Make it thread_local instead. --- cql3/query_options.cc | 4 ++-- cql3/query_options.hh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cql3/query_options.cc b/cql3/query_options.cc index 0f60414c29..8d38f00555 100644 --- a/cql3/query_options.cc +++ b/cql3/query_options.cc @@ -26,9 +26,9 @@ namespace cql3 { -const query_options::specific_options query_options::specific_options::DEFAULT{-1, {}, {}, api::missing_timestamp}; +thread_local const query_options::specific_options query_options::specific_options::DEFAULT{-1, {}, {}, api::missing_timestamp}; -default_query_options query_options::DEFAULT{db::consistency_level::ONE, +thread_local default_query_options query_options::DEFAULT{db::consistency_level::ONE, {}, false, query_options::specific_options::DEFAULT, 3, serialization_format::use_32_bit()}; } diff --git a/cql3/query_options.hh b/cql3/query_options.hh index fd886c280b..fa0c33d525 100644 --- a/cql3/query_options.hh +++ b/cql3/query_options.hh @@ -47,7 +47,7 @@ public: explicit query_options(serialization_format sf) : _serialization_format(sf) {} // Options that are likely to not be present in most queries struct specific_options final { - static const specific_options DEFAULT; + static thread_local const specific_options DEFAULT; const int32_t page_size; const ::shared_ptr state; @@ -56,7 +56,7 @@ public: }; // It can't be const because of prepare() - static default_query_options DEFAULT; + static thread_local default_query_options DEFAULT; virtual ~query_options() {}