Skip to content

check deadline before sending a message - #114

Merged
marten-seemann merged 1 commit into
libp2p:masterfrom
Asutorufa:master
Dec 13, 2023
Merged

marten-seemann merged 1 commit into
libp2p:masterfrom
Asutorufa:master

Conversation

@Asutorufa

Copy link
Copy Markdown
Contributor

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

Comment thread session.go
case <-s.shutdownCh:
return s.shutdownErr
case <-deadline:
return ErrTimeout

Copy link
Copy Markdown
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
Copy Markdown
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 <16442314+Asutorufa@users.noreply.github.com>
@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
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