transport: Make type_codec::type_id_to_type thread-local

Data type objects are thread-local so the lookup map also needs to be
thread-local. Fixes SMP issues when prepared statements are enabled
which exercise the type encoders.

Spotted by Tomek.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
This commit is contained in:
Pekka Enberg
2015-03-19 15:31:51 +02:00
parent 52eca8a4ff
commit 19978d6f4b

View File

@@ -963,7 +963,7 @@ private:
boost::bimaps::unordered_set_of<type_id>,
boost::bimaps::unordered_set_of<data_type>>;
static const type_id_to_type_type type_id_to_type;
static thread_local const type_id_to_type_type type_id_to_type;
public:
static void encode(cql_server::response& r, data_type type) {
type = type->underlying_type();
@@ -984,7 +984,7 @@ public:
}
};
const type_codec::type_id_to_type_type type_codec::type_id_to_type = boost::assign::list_of<type_id_to_type_type::relation>
thread_local const type_codec::type_id_to_type_type type_codec::type_id_to_type = boost::assign::list_of<type_id_to_type_type::relation>
(type_id::ASCII , ascii_type)
(type_id::BIGINT , long_type)
(type_id::BLOB , bytes_type)