Skip to content

Commit

Permalink
fix: ensure graphsync transport only closes complete channel once (#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkmc authored Sep 2, 2021
1 parent b0599c7 commit bcace47
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions transport/graphsync/graphsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -894,9 +894,13 @@ func (c *dtChannel) open(ctx context.Context, chid datatransfer.ChannelID, dataS
// Set up a completed channel that will be closed when the request
// completes (or is cancelled)
completed := make(chan struct{})
var onCompleteOnce sync.Once
onComplete := func() {
log.Infow("closing the completion ch for data-transfer channel", "chid", chid)
close(completed)
// Ensure the channel is only closed once
onCompleteOnce.Do(func() {
log.Infow("closing the completion ch for data-transfer channel", "chid", chid)
close(completed)
})
}
c.completed = completed

Expand Down

0 comments on commit bcace47

Please sign in to comment.