improves PeerImp logging

This commit is contained in:
Vito
2025-08-21 10:54:00 +02:00
parent 28870883bf
commit d9884eefa1
2 changed files with 23 additions and 37 deletions

View File

@@ -625,23 +625,14 @@ PeerImp::tryAsyncShutdown()
return;
if (readInProgress_ || writeInProgress_)
{
JLOG(journal_.debug())
<< "tryAsyncShutdown: waiting - read: " << readInProgress_
<< " write: " << writeInProgress_;
return;
}
shutdownStarted_ = true;
XRPL_ASSERT(
!readInProgress_ && !writeInProgress_,
"ripple::PeerImp::shutdown: read and write not in progress");
"ripple::PeerImp::tryAsyncShutdown : read and write not in progress");
JLOG(journal_.debug()) << "tryAsyncShutdown: read: " << readInProgress_
<< " write: " << writeInProgress_
<< " shutdown: " << shutdown_
<< " shutdownInProgress: " << shutdownStarted_;
setTimer();
// gracefully shutdown the SSL socket, performing a shutdown handshake
@@ -672,7 +663,6 @@ void
PeerImp::onShutdown(error_code ec)
{
cancelTimer();
JLOG(journal_.debug()) << "onShutdown";
if (ec)
{
// - eof: the stream was cleanly closed
@@ -683,7 +673,7 @@ PeerImp::onShutdown(error_code ec)
if (ec != boost::asio::error::eof &&
ec != boost::asio::error::operation_aborted)
{
JLOG(journal_.warn()) << "onShutdown: " << ec.message();
JLOG(journal_.debug()) << "onShutdown: " << ec.message();
}
}
@@ -967,11 +957,7 @@ PeerImp::onReadMessage(error_code ec, std::size_t bytes_transferred)
}
if (ec == boost::asio::error::operation_aborted)
{
JLOG(journal_.debug()) << "onReadMessage: aborted";
return tryAsyncShutdown();
}
return fail("onReadMessage", ec);
}
@@ -1025,11 +1011,6 @@ PeerImp::onReadMessage(error_code ec, std::size_t bytes_transferred)
XRPL_ASSERT(
!shutdownStarted_, "ripple::PeerImp::onReadMessage : shutdown started");
JLOG(journal_.debug()) << "onReadMessage: read: " << readInProgress_
<< " write: " << writeInProgress_
<< " shutdown: " << shutdown_
<< " shutdownInProgress: " << shutdownStarted_;
// Timeout on writes only
stream_.async_read_some(
read_buffer_.prepare(std::max(Tuning::readBufferBytes, hint)),
@@ -1050,16 +1031,14 @@ PeerImp::onWriteMessage(error_code ec, std::size_t bytes_transferred)
"ripple::PeerImp::onWriteMessage : strand in this thread");
writeInProgress_ = false;
if (!socket_.is_open())
return;
if (ec)
{
if (ec == boost::asio::error::operation_aborted)
{
JLOG(journal_.debug()) << "onWriteMessage: aborted";
return tryAsyncShutdown();
}
return fail("onWriteMessage", ec);
}

View File

@@ -175,10 +175,10 @@ private:
http_response_type response_;
boost::beast::http::fields const& headers_;
std::queue<std::shared_ptr<Message>> send_queue_;
std::atomic<bool> shutdown_ = false;
std::atomic<bool> shutdownStarted_ = false;
std::atomic<bool> readInProgress_ = false;
std::atomic<bool> writeInProgress_ = false;
bool shutdown_ = false;
bool shutdownStarted_ = false;
bool readInProgress_ = false;
bool writeInProgress_ = false;
int large_sendq_ = 0;
std::unique_ptr<LoadEvent> load_event_;
// The highest sequence of each PublisherList that has
@@ -474,23 +474,30 @@ private:
void
fail(std::string const& reason);
/**
* @brief Initiates a graceful, timed, asynchronous SSL shutdown.
/** @brief Initiates the peer disconnection sequence.
*
* This function begins the process of closing the peer connection securely.
* It first sets a timer to prevent the shutdown from hanging
* indefinitely. It then calls `async_shutdown` to perform the SSL shutdown
* handshake. The completion of this operation is handled by the
* `onShutdown` callback.
* This is the primary entry point to start closing a peer connection. It
* marks the peer for shutdown and cancels any outstanding asynchronous
* operations. This cancellation allows the graceful shutdown to proceed
* once the handlers for the cancelled operations have completed.
*
* @note This function must be called from within the object's strand.
* It is safe to call if the socket is already closed.
* @note This method must be called on the peer's strand.
*/
void
shutdown();
/** @brief Attempts to perform a graceful SSL shutdown if conditions are
* met.
*
* This helper function checks if the peer is in a state where a graceful
* SSL shutdown can be performed (i.e., shutdown has been requested and no
* I/O operations are currently in progress).
*
* @note This method must be called on the peer's strand.
*/
void
tryAsyncShutdown();
/**
* @brief Handles the completion of the asynchronous SSL shutdown.
*