Skip to content

Commit

Permalink
PROTON-2843: [Go] Fix segfault on settling a message on closed receivers
Browse files Browse the repository at this point in the history
Deliveries can not be settled after the receiver has been freed. Therefore, this adds a check to ensure that the receiver was not closed (which ensures that `Free` has not been called on the link yet)
  • Loading branch information
PatrickTaibel committed Sep 5, 2024
1 parent dc1c39f commit 561c9a2
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions go/pkg/electron/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
)

// Receiver is a Link that receives messages.
//
type Receiver interface {
Endpoint
LinkSettings
Expand Down Expand Up @@ -201,9 +200,15 @@ type ReceivedMessage struct {

// Acknowledge a ReceivedMessage with the given delivery status.
func (rm *ReceivedMessage) acknowledge(status uint64) error {
return rm.receiver.(*receiver).engine().Inject(func() {
// Deliveries are valid as long as the connection is, unless settled.
rm.pDelivery.SettleAs(uint64(status))
return rm.receiver.(*receiver).engine().InjectWait(func() error {
// Deliveries are valid as long as the receiver is, unless settled.
select {
case <-rm.receiver.Done():
return rm.receiver.Error()
default:
rm.pDelivery.SettleAs(uint64(status))
}
return nil
})
}

Expand Down

0 comments on commit 561c9a2

Please sign in to comment.