From 802b3fdf19d47a1a39b82a5bb66dd184342fed70 Mon Sep 17 00:00:00 2001 From: Asias He Date: Fri, 7 Aug 2015 09:10:38 +0800 Subject: [PATCH] gossip: Add timeout to send_gossip Otherwise, when a node tries to send to a just killed node, it will block for a long time, thus gossip round will be blocked. --- gms/gossiper.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gms/gossiper.cc b/gms/gossiper.cc index c8f75b7d55..a5e2517285 100644 --- a/gms/gossiper.cc +++ b/gms/gossiper.cc @@ -38,6 +38,7 @@ #include "log.hh" #include #include +#include #include namespace gms { @@ -241,8 +242,9 @@ future gossiper::send_gossip(gossip_digest_syn message, std::set(); logger.trace("Sending a GossipDigestSyn to {} ...", id); - return ms().send_gossip_digest_syn(id, std::move(message)).then_wrapped([this, id] (auto&& f) { + ms().send_gossip_digest_syn(id, std::move(message)).then_wrapped([this, id, sem] (auto&& f) { try { auto ack_msg = f.get0(); logger.trace("Got GossipDigestSyn Reply"); @@ -254,7 +256,11 @@ future gossiper::send_gossip(gossip_digest_syn message, std::set(); - }).then([this, to] { + }).then([sem] { + sem->signal(); + }); + + return sem->wait(std::chrono::milliseconds(1000)).then([this, to] { return make_ready_future(_seeds.count(to)); }); }