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

Remove default case #341

Merged
merged 3 commits into from
Nov 17, 2021
Merged
Changes from 2 commits
Commits
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
30 changes: 17 additions & 13 deletions p2p/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,19 +399,23 @@ func createMConnection(
// because msgBytes is on socket receive buffer yet so reactor can read it concurrently
copied := make([]byte, len(msgBytes))
copy(copied, msgBytes)
select {
case ch <- &BufferedMsg{
ChID: chID,
Peer: p,
Msg: copied}:
default:
// if the channel is full, we abandon this message
// Should check `config.Config.XxxBufSize`
p.Logger.Error("Lost the message since BaseReactor.recvMsgBuf is full",
"reactor", reactor,
"msgBytes.len", len(msgBytes), "msgBytes", fmt.Sprintf("%X", msgBytes))
p.metrics.NumAbandonedPeerMsgs.With(labels...).Add(1)
}
ch <- &BufferedMsg{ChID: chID, Peer: p, Msg: copied}
/*
select {
case ch <- &BufferedMsg{
ChID: chID,
Peer: p,
Msg: copied}:
// Remove `default` case since shouldn't abandon message although blocking sending message into golang channel
//default:
// // if the channel is full, we abandon this message
// // Should check `config.Config.XxxBufSize`
// p.Logger.Error("Lost the message since BaseReactor.recvMsgBuf is full",
// "reactor", reactor,
// "msgBytes.len", len(msgBytes), "msgBytes", fmt.Sprintf("%X", msgBytes))
// p.metrics.NumAbandonedPeerMsgs.With(labels...).Add(1)
}
*/
torao marked this conversation as resolved.
Show resolved Hide resolved
} else {
reactor.Receive(chID, p, msgBytes)
}
Expand Down