Skip to content

Commit

Permalink
transport: Fix double release of incoming message
Browse files Browse the repository at this point in the history
This fixes the double release panic introduced in the prior commit. The
panic was only introduced to prove that double release is possible happening.

Note: In my (matheusd) opinion, Release() calls should panic or error in
case of double release so that callers are fixed and they themselves do
not rely on this protection. This is suggested as a future change
because it potentially breaks clients that were relying on this
protection.
  • Loading branch information
matheusd committed Aug 13, 2024
1 parent 8e57c45 commit 6000253
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions rpc/transport/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,7 @@ func (i *incomingMsg) Message() rpccp.Message {
}

func (i *incomingMsg) Release() {
if m := i.Message().Message(); m != nil {
if i.released {
panic("double release")
}
if m := i.Message().Message(); !i.released && m != nil {
i.released = true
m.Release()
}
Expand Down

0 comments on commit 6000253

Please sign in to comment.