This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Fix tried to send handshake twice #5413
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5ad08ff
Fix tried to send handshake twice
tomaka 44ebdad
Fix wrong boolean
tomaka 387a143
Change to debug
tomaka d6f240e
Merge remote-tracking branch 'upstream/master' into HEAD
tomaka a7b7440
Merge branch 'master' into fix-handshake-twice
tomaka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -164,12 +164,9 @@ where TSubstream: AsyncRead + AsyncWrite, | |
| { | ||
| /// Sends the handshake in order to inform the remote that we accept the substream. | ||
| pub fn send_handshake(&mut self, message: impl Into<Vec<u8>>) { | ||
| match self.handshake { | ||
| NotificationsInSubstreamHandshake::NotSent => {} | ||
| _ => { | ||
| error!(target: "sub-libp2p", "Tried to send handshake twice"); | ||
| return; | ||
| } | ||
| if !matches!(self.handshake, NotificationsInSubstreamHandshake::NotSent) { | ||
| error!(target: "sub-libp2p", "Tried to send handshake twice"); | ||
| return; | ||
| } | ||
|
|
||
| self.handshake = NotificationsInSubstreamHandshake::PendingSend(message.into()); | ||
|
|
@@ -189,8 +186,10 @@ where TSubstream: AsyncRead + AsyncWrite + Unpin, | |
| match mem::replace(this.handshake, NotificationsInSubstreamHandshake::Sent) { | ||
| NotificationsInSubstreamHandshake::Sent => | ||
| return Stream::poll_next(this.socket.as_mut(), cx), | ||
| NotificationsInSubstreamHandshake::NotSent => | ||
| return Poll::Pending, | ||
| NotificationsInSubstreamHandshake::NotSent => { | ||
| *this.handshake = NotificationsInSubstreamHandshake::NotSent; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The main bugfix is here. |
||
| return Poll::Pending | ||
| }, | ||
| NotificationsInSubstreamHandshake::PendingSend(msg) => | ||
| match Sink::poll_ready(this.socket.as_mut(), cx) { | ||
| Poll::Ready(_) => { | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.