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

check deadline before sending a message #114

Merged
merged 1 commit into from
Dec 13, 2023

Conversation

Asutorufa
Copy link
Contributor

check deadline before sendMsg, because select is randomly, sometimes it will write successfully after deadline

@@ -487,6 +487,8 @@ func (s *Session) sendMsg(hdr header, body []byte, deadline <-chan struct{}) err
select {
case <-s.shutdownCh:
return s.shutdownErr
case <-deadline:
return ErrTimeout
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be a separate select statement after this one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right, the shutdownErr should preferred.

…it will write successfully after deadline

Signed-off-by: Asutorufa <[email protected]>
@marten-seemann marten-seemann changed the title check deadline before sendMsg check deadline before sending a message Dec 13, 2023
@marten-seemann marten-seemann merged commit 4c58128 into libp2p:master Dec 13, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants