Consume future outside of client scope (#1466)

This commit is contained in:
clemahieu 2018-12-16 17:44:14 +01:00 committed by Roy Keene
commit d46621dbab

View file

@ -809,7 +809,7 @@ bool rai::bootstrap_attempt::request_frontier (std::unique_lock<std::mutex> & lo
future = client->promise.get_future ();
}
lock_a.unlock ();
result = consume_future (future);
result = consume_future (future); // This is out of scope of `client' so when the last reference via boost::asio::io_service is lost and the client is destroyed, the future throws an exception.
lock_a.lock ();
if (result)
{
@ -862,12 +862,15 @@ void rai::bootstrap_attempt::request_push (std::unique_lock<std::mutex> & lock_a
bool error (false);
if (auto connection_shared = connection_frontier_request.lock ())
{
auto client (std::make_shared<rai::bulk_push_client> (connection_shared));
client->start ();
push = client;
auto future (client->promise.get_future ());
std::future<bool> future;
{
auto client (std::make_shared<rai::bulk_push_client> (connection_shared));
client->start ();
push = client;
future = client->promise.get_future ();
}
lock_a.unlock ();
error = consume_future (future);
error = consume_future (future); // This is out of scope of `client' so when the last reference via boost::asio::io_service is lost and the client is destroyed, the future throws an exception.
lock_a.lock ();
}
if (node->config.logging.network_logging ())