Skip to content

Commit

Permalink
go/worker/storage: Fix potential memory leak through context
Browse files Browse the repository at this point in the history
  • Loading branch information
kostko committed Sep 30, 2021
1 parent 6df3e80 commit 3c71017
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion go/worker/storage/committee/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,9 +529,12 @@ func (n *Node) fetchDiff(round uint64, prevRoot, thisRoot storageApi.Root) {
"new_root", thisRoot,
)

ctx, cancel := context.WithCancel(n.ctx)
defer cancel()

// Prioritize committee nodes.
var selectedNode *node.Node
ctx := storageApi.WithNodeSelectionCallback(n.ctx, func(n *node.Node) {
ctx = storageApi.WithNodeSelectionCallback(ctx, func(n *node.Node) {
selectedNode = n
})
if committee := n.commonNode.Group.GetEpochSnapshot().GetStorageCommittee(); committee != nil {
Expand Down

0 comments on commit 3c71017

Please sign in to comment.