Skip to content

Commit 943c68c

Browse files
authored
Merge pull request apache#8 from jul-stas/fix-race-sharding-info-getter
Host: `ShardingInfo` is copied under a mutex in getter
2 parents b54c802 + 6287c1a commit 943c68c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/host.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,12 @@ class Host final : public RefCounted<Host> {
133133
dc_id_ = dc_id;
134134
}
135135

136-
CassOptional<ShardingInfo> sharding_info() const { return sharding_info_opt_; }
136+
CassOptional<ShardingInfo> sharding_info() {
137+
ScopedMutex lock(&mutex_);
138+
auto tmp = sharding_info_opt_;
139+
return tmp;
140+
}
141+
137142
void set_sharding_info_if_unset(ShardingInfo si) {
138143
ScopedMutex lock(&mutex_);
139144
if (!sharding_info_opt_) {

0 commit comments

Comments
 (0)