未验证 提交 e491b6c9 编写于 作者: M Matt Witherspoon 提交者: GitHub

Merge pull request #2458 from EOSIO/tolerate-network-errors-udp-socket-2457

Retry asio::error::would_block, ignore all other exceptions in send_to
......@@ -48,17 +48,18 @@ namespace fc
}
catch(const boost::system::system_error& e)
{
if(e.code() != boost::asio::error::would_block)
throw;
if(e.code() == boost::asio::error::would_block)
{
auto send_buffer_ptr = std::make_shared<std::vector<char>>(buffer, buffer+length);
my->_sock->async_send_to(boost::asio::buffer(send_buffer_ptr.get(), length), to,
[send_buffer_ptr](const boost::system::error_code& /*ec*/, std::size_t /*bytes_transferred*/)
{
// Swallow errors. Currently only used for GELF logging, so depend on local
// log to catch anything that doesn't make it across the network.
});
}
// All other exceptions ignored.
}
auto send_buffer_ptr = std::make_shared<std::vector<char>>(buffer, buffer+length);
my->_sock->async_send_to(boost::asio::buffer(send_buffer_ptr.get(), length), to,
[send_buffer_ptr](const boost::system::error_code& /*ec*/, std::size_t /*bytes_transferred*/)
{
// Swallow errors. Currently only used for GELF logging, so depend on local
// log to catch anything that doesn't make it across the network.
});
}
void udp_socket::send_to(const std::shared_ptr<const char>& buffer, size_t length,
......@@ -71,17 +72,18 @@ namespace fc
}
catch(const boost::system::system_error& e)
{
if(e.code() != boost::asio::error::would_block)
throw;
if(e.code() == boost::asio::error::would_block)
{
auto preserved_buffer_ptr = buffer;
my->_sock->async_send_to(boost::asio::buffer(preserved_buffer_ptr.get(), length), to,
[preserved_buffer_ptr](const boost::system::error_code& /*ec*/, std::size_t /*bytes_transferred*/)
{
// Swallow errors. Currently only used for GELF logging, so depend on local
// log to catch anything that doesn't make it across the network.
});
}
// All other exceptions ignored.
}
auto preserved_buffer_ptr = buffer;
my->_sock->async_send_to(boost::asio::buffer(preserved_buffer_ptr.get(), length), to,
[preserved_buffer_ptr](const boost::system::error_code& /*ec*/, std::size_t /*bytes_transferred*/)
{
// Swallow errors. Currently only used for GELF logging, so depend on local
// log to catch anything that doesn't make it across the network.
});
}
void udp_socket::open()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册