Skip to content

Commit

Permalink
Add mutex around peers.get<T>() (#1291)
Browse files Browse the repository at this point in the history
  • Loading branch information
rkeene authored Oct 11, 2018
1 parent d13d23c commit f17bee5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions rai/node/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3303,9 +3303,14 @@ bool rai::peer_container::contacted (rai::endpoint const & endpoint_a, unsigned
{
insert (endpoint_l, version_a);
}
else if (!known_peer (endpoint_l) && peers.get<rai::peer_by_ip_addr> ().count (endpoint_l.address ()) < max_peers_per_ip)
else if (!known_peer (endpoint_l))
{
should_handshake = true;
std::lock_guard<std::mutex> lock (mutex);

if (peers.get<rai::peer_by_ip_addr> ().count (endpoint_l.address ()) < max_peers_per_ip)
{
should_handshake = true;
}
}
return should_handshake;
}
Expand Down

0 comments on commit f17bee5

Please # to comment.