Skip to content
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

General clean-up of the single stream connections code #2708

Merged
merged 25 commits into from
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
bec0190
Add some code comments
tomaka Aug 30, 2022
1fa5cb1
Remove the update_all method and inline it
tomaka Aug 30, 2022
85c864d
Typo: peer -> ping
tomaka Aug 30, 2022
aacce8b
Decode data frames in two steps
tomaka Aug 30, 2022
b11121d
Remove pending_events field
tomaka Aug 30, 2022
4b7a308
Call substream.reserve_window
tomaka Aug 30, 2022
1e3e419
Add a NewOutboundSubstreamsForbidden event
tomaka Aug 30, 2022
33f0182
Forbid new substreams after a GoAway frame
tomaka Aug 30, 2022
bc38ae9
Remove num_ping_failed_events field
tomaka Aug 30, 2022
7c21a9c
Merge branch 'main' into single-stream-improve
tomaka Aug 31, 2022
d2e3a42
Merge branch 'main' into single-stream-improve
tomaka Aug 31, 2022
480475e
More all yamux operations within a single loop
tomaka Sep 1, 2022
5b213ec
Add Yamux::is_empty
tomaka Sep 1, 2022
9104584
Add Yamux::send_goaway
tomaka Sep 1, 2022
aafb99b
Properly handle shutdown phase
tomaka Sep 1, 2022
753c1eb
Add SingleStream::deny_new_incoming_substreams
tomaka Sep 1, 2022
7e6ded7
Remove TODO about GoAway frames
tomaka Sep 1, 2022
b8735fe
Remove obsolete TODO in yamux
tomaka Sep 1, 2022
9792928
Add CHANGELOG entry
tomaka Sep 1, 2022
8f13baf
Fix missing continue
tomaka Sep 1, 2022
471dce0
Fix docs and spellcheck
tomaka Sep 1, 2022
49d1760
Only close connection if GoAway has been sent
tomaka Sep 2, 2022
38bf91f
Fix potential infinite loop in Yamux
tomaka Sep 2, 2022
1ef9fef
Merge branch 'main' into single-stream-improve
tomaka Sep 6, 2022
a6f037a
Merge branch 'main' into single-stream-improve
tomaka Sep 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/libp2p/collection/multi_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,15 @@ where
outbound_substreams_reverse,
} => {
let event = match established.pull_event() {
Some(established::Event::NewOutboundSubstreamsForbidden) => {
// TODO: handle properly
self.connection = MultiStreamConnectionTaskInner::ShutdownWaitingAck {
start_shutdown_message_to_send: Some(None),
shutdown_finish_message_sent: false,
initiator: ShutdownInitiator::Coordinator,
};
Some(ConnectionToCoordinatorInner::StartShutdown(None))
}
Some(established::Event::InboundError(err)) => {
Some(ConnectionToCoordinatorInner::InboundError(err))
}
Expand Down
14 changes: 14 additions & 0 deletions src/libp2p/collection/single_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,20 @@ where
}

match event {
Some(established::Event::NewOutboundSubstreamsForbidden) => {
// TODO: handle properly
self.pending_messages.push_back(
ConnectionToCoordinatorInner::StartShutdown(Some(
ShutdownCause::CleanShutdown,
)),
);
self.pending_messages
.push_back(ConnectionToCoordinatorInner::ShutdownFinished);
self.connection = SingleStreamConnectionTaskInner::ShutdownWaitingAck {
initiator: ShutdownInitiator::Remote,
};
return;
}
Some(established::Event::InboundError(err)) => {
self.pending_messages
.push_back(ConnectionToCoordinatorInner::InboundError(err));
Expand Down
5 changes: 5 additions & 0 deletions src/libp2p/connection/established.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ impl SubstreamId {
#[must_use]
#[derive(Debug)]
pub enum Event<TRqUd, TNotifUd> {
/// The connection is now in a mode where opening new substreams (i.e. starting requests
/// and opening notifications substreams) is forbidden, but the remote is still able to open
/// substreams and messages on existing substreams are still allowed to be sent and received.
NewOutboundSubstreamsForbidden,

/// Received an incoming substream, but this substream has produced an error.
///
/// > **Note**: This event exists only for diagnostic purposes. No action is expected in
Expand Down
Loading