1
0
Fork 0

fixed r/w deadlock

This commit is contained in:
Jan Steemann 2013-12-20 16:27:54 +01:00
parent c460ab97e9
commit 5a3b49a7bc
1 changed files with 15 additions and 11 deletions

View File

@ -133,18 +133,22 @@ std::string ClusterState::getServerEndpoint (ServerID const& serverID) {
return string("");
}
ServerID ClusterState::getResponsibleServer (ShardID const& shardID)
{
READ_LOCKER(lock);
map<ShardID,ServerID>::iterator i = shards.find(shardID);
if (i != shards.end()) {
return i->second;
}
loadShardInformation();
i = shards.find(shardID);
if (i != shards.end()) {
return i->second;
ServerID ClusterState::getResponsibleServer (ShardID const& shardID) {
int tries = 0;
while (++tries < 3) {
{
READ_LOCKER(lock);
map<ShardID,ServerID>::iterator i = shards.find(shardID);
if (i != shards.end()) {
return i->second;
}
}
// must call loadShardInformation outside the lock
loadShardInformation();
}
return ServerID("");
}