Skip to content

Commit

Permalink
protoboard: bail with error on peer overflow
Browse files Browse the repository at this point in the history
It's probably better to just print an error instead of crashing the
entire framework if someone tries to create too many peers. There's just
too many places this can be triggered from.
  • Loading branch information
vmatare committed Dec 4, 2019
1 parent 6c9a47e commit 98cfe88
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/libs/protoboard/blackboard_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ BlackboardManager::get_blackboard()
void
BlackboardManager::add_peer(ProtobufPeerInterface *iface, long peer_id)
{
if (next_peer_idx_ >= iface->maxlenof_peers()) {
logger->log_error(name(),
"Maximum number of peers reached. Can't create new peer with index %d!",
next_peer_idx_);
return;
}
iface->set_peers(next_peer_idx_++, peer_id);
iface->write();
}
Expand Down

0 comments on commit 98cfe88

Please sign in to comment.