mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
cleans up assets in PeerImp
This commit is contained in:
@@ -617,13 +617,9 @@ PeerImp::fail(std::string const& reason)
|
|||||||
void
|
void
|
||||||
PeerImp::tryAsyncShutdown()
|
PeerImp::tryAsyncShutdown()
|
||||||
{
|
{
|
||||||
if (!strand_.running_in_this_thread())
|
XRPL_ASSERT(
|
||||||
return post(
|
strand_.running_in_this_thread(),
|
||||||
strand_, std::bind(&PeerImp::tryAsyncShutdown, shared_from_this()));
|
"ripple::PeerImp::tryAsyncShutdown : strand in this thread");
|
||||||
|
|
||||||
// XRPL_ASSERT(
|
|
||||||
// strand_.running_in_this_thread(),
|
|
||||||
// "ripple::PeerImp::shutdown: strand in this thread");
|
|
||||||
|
|
||||||
if (!shutdown_ || shutdownStarted_)
|
if (!shutdown_ || shutdownStarted_)
|
||||||
return;
|
return;
|
||||||
@@ -647,45 +643,27 @@ PeerImp::tryAsyncShutdown()
|
|||||||
<< " shutdown: " << shutdown_
|
<< " shutdown: " << shutdown_
|
||||||
<< " shutdownInProgress: " << shutdownStarted_;
|
<< " shutdownInProgress: " << shutdownStarted_;
|
||||||
setTimer();
|
setTimer();
|
||||||
|
|
||||||
// gracefully shutdown the SSL socket, performing a shutdown handshake
|
// gracefully shutdown the SSL socket, performing a shutdown handshake
|
||||||
stream_.async_shutdown(bind_executor(
|
stream_.async_shutdown(bind_executor(
|
||||||
strand_,
|
strand_,
|
||||||
std::bind(
|
std::bind(
|
||||||
&PeerImp::onShutdown, shared_from_this(), std::placeholders::_1)));
|
&PeerImp::onShutdown, shared_from_this(), std::placeholders::_1)));
|
||||||
// stream_.async_shutdown([this](error_code ec) {
|
|
||||||
// cancelTimer();
|
|
||||||
// close();
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PeerImp::shutdown()
|
PeerImp::shutdown()
|
||||||
{
|
{
|
||||||
// XRPL_ASSERT(
|
XRPL_ASSERT(
|
||||||
// strand_.running_in_this_thread(),
|
strand_.running_in_this_thread(),
|
||||||
// "ripple::PeerImp::shutdown: strand in this thread");
|
"ripple::PeerImp::shutdown: strand in this thread");
|
||||||
if (!strand_.running_in_this_thread())
|
|
||||||
return post(strand_, std::bind(&PeerImp::shutdown, shared_from_this()));
|
|
||||||
|
|
||||||
if (!socket_.is_open())
|
if (!socket_.is_open())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
shutdown_ = true;
|
shutdown_ = true;
|
||||||
|
|
||||||
JLOG(journal_.debug()) << "shutdown";
|
|
||||||
// cancel asynchronous I/O
|
|
||||||
// error_code ec;
|
|
||||||
// auto ret = socket_.cancel(ec);
|
|
||||||
boost::beast::get_lowest_layer(stream_).cancel();
|
boost::beast::get_lowest_layer(stream_).cancel();
|
||||||
// if (ec)
|
|
||||||
// {
|
|
||||||
// JLOG(journal_.debug()) << "shutdown: cancel err: " << ec.what();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (ret)
|
|
||||||
// {
|
|
||||||
// JLOG(journal_.debug()) << "shutdown: cancel err: " << ret.what();
|
|
||||||
// }
|
|
||||||
|
|
||||||
tryAsyncShutdown();
|
tryAsyncShutdown();
|
||||||
};
|
};
|
||||||
@@ -903,7 +881,7 @@ PeerImp::doAccept()
|
|||||||
if (!socket_.is_open())
|
if (!socket_.is_open())
|
||||||
return;
|
return;
|
||||||
if (ec == boost::asio::error::operation_aborted)
|
if (ec == boost::asio::error::operation_aborted)
|
||||||
return;
|
return tryAsyncShutdown();
|
||||||
if (ec)
|
if (ec)
|
||||||
return fail("onWriteResponse", ec);
|
return fail("onWriteResponse", ec);
|
||||||
if (write_buffer->size() == bytes_transferred)
|
if (write_buffer->size() == bytes_transferred)
|
||||||
@@ -1069,7 +1047,7 @@ PeerImp::onWriteMessage(error_code ec, std::size_t bytes_transferred)
|
|||||||
{
|
{
|
||||||
XRPL_ASSERT(
|
XRPL_ASSERT(
|
||||||
strand_.running_in_this_thread(),
|
strand_.running_in_this_thread(),
|
||||||
"ripple::PeerImp::fail : strand in this thread");
|
"ripple::PeerImp::onWriteMessage : strand in this thread");
|
||||||
|
|
||||||
writeInProgress_ = false;
|
writeInProgress_ = false;
|
||||||
if (!socket_.is_open())
|
if (!socket_.is_open())
|
||||||
@@ -1107,6 +1085,10 @@ PeerImp::onWriteMessage(error_code ec, std::size_t bytes_transferred)
|
|||||||
if (!send_queue_.empty())
|
if (!send_queue_.empty())
|
||||||
{
|
{
|
||||||
writeInProgress_ = true;
|
writeInProgress_ = true;
|
||||||
|
XRPL_ASSERT(
|
||||||
|
!shutdownStarted_,
|
||||||
|
"ripple::PeerImp::onWriteMessage : shutdown started");
|
||||||
|
|
||||||
// Timeout on writes only
|
// Timeout on writes only
|
||||||
return boost::asio::async_write(
|
return boost::asio::async_write(
|
||||||
stream_,
|
stream_,
|
||||||
|
|||||||
Reference in New Issue
Block a user