Commit ac3a64d8 authored by rht's avatar rht

Localize the scope of context.WithCancel for every DAG.Get

Instead put it inside of DAG.Get.
The fix is applied only in the case when the context.WithCancel
before a DAG.Get is also used later on in the scope.

License: MIT
Signed-off-by: default avatarrht <rhtbot@gmail.com>
parent 8f176c05
......@@ -459,9 +459,6 @@ func dagTruncate(ctx context.Context, nd *mdag.Node, size uint64, ds mdag.DAGSer
var modified *mdag.Node
ndata := new(ft.FSNode)
for i, lnk := range nd.Links {
_ctx, cancel := context.WithCancel(ctx)
defer cancel()
child, err := lnk.GetNode(ctx, ds)
if err != nil {
return nil, err
......@@ -474,7 +471,7 @@ func dagTruncate(ctx context.Context, nd *mdag.Node, size uint64, ds mdag.DAGSer
// found the child we want to cut
if size < cur+childsize {
nchild, err := dagTruncate(_ctx, child, size-cur, ds)
nchild, err := dagTruncate(ctx, child, size-cur, ds)
if err != nil {
return nil, err
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment