-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat: Adds peer disconnection message #5755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
This commit refactors the peer shutdown and failure handling mechanism to be more robust, consistent, and communicative. The previous implementation used raw strings to represent error reasons and did not communicate these reasons to peers when shutting down a connection. With this change disconnections are now explicitly communicated via a `TMClose` protocol message with strongly-typed reasons. This new approach provides better diagnostics and makes the peer disconnection process more stable and predictable.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #5755 +/- ##
=========================================
- Coverage 78.7% 78.7% -0.0%
=========================================
Files 816 816
Lines 71749 71757 +8
Branches 8475 8479 +4
=========================================
- Hits 56456 56440 -16
- Misses 15293 15317 +24
🚀 New features to boost your workflow:
|
} | ||
|
||
void | ||
PeerImp::gracefulClose() | ||
PeerImp::sendAndClose(protocol::TMCloseReason reason) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not really sendAndClose
since it doesn't close the socket. It indicates an intention to close.
@@ -231,7 +259,8 @@ PeerImp::stop() | |||
JLOG(journal_.info()) << "Stop"; | |||
} | |||
} | |||
close(); | |||
|
|||
sendAndClose(protocol::TMCloseReason::crSHUTDOWN); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think close()
should be called here as in the original implementation. The overlay received stop()
request. IMO it should close right away.
Also I'm not sure if sendAndClose()
would actually close the socket. send()
has this code at the start of the function:
auto validator = m->getValidatorKey();
if (validator && !squelch_.expireSquelch(*validator))
{
overlay_.reportOutboundTraffic(
TrafficCount::category::squelch_suppressed,
static_cast<int>(m->getBuffer(compressionEnabled_).size()));
return;
}
If that condition above is true then send()
is not going to send anything. And if the send queue is empty then onWriteMessage()
is not going to be called and consequently close()
is not going to be called.
JLOG(journal_.info()) << "EOF"; | ||
return gracefulClose(); | ||
return close(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think gracefulClose()
should still be called. gracefulClose()
calls async_shutdown
, which is graceful and secure connection shutdown, especially with SSL/TLS streams. Calling close() might be an ungraceful and often insecure way to terminate a connection.
This PR refactors the peer shutdown and failure handling mechanism to be more robust, consistent, and communicative.
The previous implementation used raw strings to represent error reasons and did not communicate these reasons to peers when shutting down a connection.
With this change disconnections are now explicitly communicated via a
TMClose
protocol message with strongly-typed reasons. This new approach provides better diagnostics and makes the peer disconnection process more stable and predictable.A similar feature was implemented in #3839 by @gregtatcam, which introduced start
and
shutdown` messages. This is a simplified version of that change, introducing only a shutdown message.This feature is backwards compatible, as older
rippled
versions ignore unknown p2p protocol messages.Example log message:
High Level Overview of Change
Context of Change
Type of Change
.gitignore
, formatting, dropping support for older tooling)API Impact
libxrpl
change (any change that may affectlibxrpl
or dependents oflibxrpl
)