Skip to content

Commit

Permalink
proof: ensure that recv ACK stream is closed correctly
Browse files Browse the repository at this point in the history
This commit modifies the `HashMailBox.RecvAck` method to ensure that the
receive ACK gRPC stream is closed successfully.
  • Loading branch information
ffranr committed Nov 7, 2024
1 parent 7112f93 commit 2259410
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions proof/courier.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,17 @@ func (h *HashMailBox) RecvAck(ctx context.Context, sid streamID) error {
return fmt.Errorf("unable to create read stream: %w", err)
}

// Ensure the read stream is closed before returning.
defer func() {
log.Debugf("Closing hashmail read stream (sid=%x)", sid[:])

err := readStream.CloseSend()
if err != nil {
log.Errorf("Unable to close hashmail read stream "+
"(sid=%x): %v", sid[:], err)
}
}()

log.Debugf("Exec stream Recv for receiver ACK (sid=%x)", sid[:])
msg, err := readStream.Recv()
if err != nil {
Expand Down

0 comments on commit 2259410

Please sign in to comment.