Skip to content

Commit

Permalink
Fix PeerManager::NextPeer to take parameter by const reference
Browse files Browse the repository at this point in the history
Change-Id: I343b37b019860cac1c6db4533d589f08d8a9a2a6
Partial-Bug: 1548570
  • Loading branch information
Nischal Sheth committed Jun 29, 2016
1 parent d0ac986 commit 3123c59
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/bgp/bgp_show_neighbor.cc
Expand Up @@ -28,7 +28,7 @@ static bool FillBgpNeighborInfoList(const BgpSandeshContext *bsc,
rtinstance->peer_manager()->FillBgpNeighborInfo(
bsc, show_list, search_string, summary);

BgpPeer *peer = bsc->bgp_server->FindNextPeer();
const BgpPeer *peer = bsc->bgp_server->FindNextPeer();
while (peer) {
if (search_string.empty() ||
(peer->peer_basename().find(search_string) != string::npos) ||
Expand Down
15 changes: 2 additions & 13 deletions src/bgp/routing-instance/peer_manager.cc
Expand Up @@ -239,22 +239,10 @@ BgpPeer *PeerManager::PeerLookup(TcpSession::Endpoint remote_endpoint) const {
return peer;
}

BgpPeer *PeerManager::NextPeer(BgpPeerKey &peer_key) {
// Do a partial match
BgpPeerKeyMap::iterator loc = peers_by_key_.upper_bound(peer_key);
if (loc != peers_by_key_.end()) {
peer_key = loc->second->peer_key();
return loc->second;
}

return NULL;
}

const BgpPeer *PeerManager::NextPeer(BgpPeerKey &peer_key) const {
const BgpPeer *PeerManager::NextPeer(const BgpPeerKey &peer_key) const {
// Do a partial match
BgpPeerKeyMap::const_iterator loc = peers_by_key_.upper_bound(peer_key);
if (loc != peers_by_key_.end()) {
peer_key = loc->second->peer_key();
return loc->second;
}

Expand Down Expand Up @@ -282,5 +270,6 @@ void PeerManager::FillBgpNeighborInfo(const BgpSandeshContext *bsc,
peer->FillNeighborInfo(bsc, &bnr, summary);
bnr_list->push_back(bnr);
}
key = peer->peer_key();
}
}
3 changes: 1 addition & 2 deletions src/bgp/routing-instance/peer_manager.h
Expand Up @@ -39,8 +39,7 @@ class PeerManager {
virtual void DestroyIPeer(IPeer *ipeer);
void ClearAllPeers();

virtual BgpPeer *NextPeer(BgpPeerKey &key);
virtual const BgpPeer *NextPeer(BgpPeerKey &key) const;
const BgpPeer *NextPeer(const BgpPeerKey &key) const;

void FillBgpNeighborInfo(const BgpSandeshContext *bsc,
std::vector<BgpNeighborResp> *sbnr_list,
Expand Down

0 comments on commit 3123c59

Please sign in to comment.