Skip to content

Commit

Permalink
fix curvefs mds get metaserver
Browse files Browse the repository at this point in the history
Signed-off-by: wanghai01 <seanhaizi@163.com>
  • Loading branch information
SeanHai committed Sep 12, 2023
1 parent 30ce10b commit 0897e58
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions curvefs/src/mds/topology/topology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,15 +532,19 @@ bool TopologyImpl::GetMetaServer(MetaServerIdType metaserverId,
bool TopologyImpl::GetMetaServer(const std::string &hostIp, uint32_t port,
MetaServer *out) const {
ReadLockGuard rlockMetaServerMap(metaServerMutex_);
bool find = false;
for (auto it = metaServerMap_.begin(); it != metaServerMap_.end(); it++) {
ReadLockGuard rlockMetaServer(it->second.GetRWLockRef());
if (it->second.GetInternalIp() == hostIp &&
it->second.GetInternalPort() == port) {
*out = it->second;
return true;
find = true;
if (it->second.GetOnlineState() == OnlineState::ONLINE) {
return find;
}
}
}
return false;
return find;
}

TopoStatusCode TopologyImpl::AddPartition(const Partition &data) {
Expand Down Expand Up @@ -1628,6 +1632,7 @@ uint32_t TopologyImpl::GetPartitionIndexOfFS(FsIdType fsId) {

std::vector<CopySetInfo> TopologyImpl::ListCopysetInfo() const {
std::vector<CopySetInfo> ret;
ReadLockGuard rlockCopySet(copySetMutex_);
for (auto const &i : copySetMap_) {
ret.emplace_back(i.second);
}
Expand Down

0 comments on commit 0897e58

Please sign in to comment.