From 3dae58e30718ff1a46ae9e3100a8ad99b02ca888 Mon Sep 17 00:00:00 2001 From: Andrei Lebedev Date: Fri, 20 Sep 2019 12:37:17 +0300 Subject: [PATCH] Yac: recreate channel and stub on each send Signed-off-by: Andrei Lebedev --- irohad/consensus/yac/transport/impl/network_impl.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/irohad/consensus/yac/transport/impl/network_impl.cpp b/irohad/consensus/yac/transport/impl/network_impl.cpp index cdb5384d56d..828d4ba0951 100644 --- a/irohad/consensus/yac/transport/impl/network_impl.cpp +++ b/irohad/consensus/yac/transport/impl/network_impl.cpp @@ -15,6 +15,10 @@ #include "logger/logger.hpp" #include "yac.pb.h" +namespace { + const std::chrono::seconds kSendStateTimeout{5}; +} // namespace + namespace iroha { namespace consensus { namespace yac { @@ -46,6 +50,9 @@ namespace iroha { } async_call_->Call([&](auto context, auto cq) { + // set a timeout to avoid being hung + context->set_deadline(std::chrono::system_clock::now() + + kSendStateTimeout); return peers_.at(to.address())->AsyncSendState(context, request, cq); }); @@ -86,9 +93,7 @@ namespace iroha { void NetworkImpl::createPeerConnection( const shared_model::interface::Peer &peer) { - if (peers_.count(peer.address()) == 0) { - peers_[peer.address()] = client_creator_(peer); - } + peers_[peer.address()] = client_creator_(peer); } } // namespace yac