Commit dbcf68e9 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 7993a94b
......@@ -93,6 +93,8 @@ func (n *dagService) Get(ctx context.Context, k key.Key) (*Node, error) {
if n == nil {
return nil, fmt.Errorf("dagService is nil")
}
ctx, cancel := context.WithCancel(ctx)
defer cancel()
b, err := n.Blocks.GetBlock(ctx, k)
if err != nil {
......
......@@ -3,7 +3,6 @@ package traverse
import (
"errors"
"time"
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
......@@ -67,10 +66,7 @@ func (t *traversal) callFunc(next State) error {
func (t *traversal) getNode(link *mdag.Link) (*mdag.Node, error) {
getNode := func(l *mdag.Link) (*mdag.Node, error) {
ctx, cancel := context.WithTimeout(context.TODO(), time.Minute)
defer cancel()
next, err := l.GetNode(ctx, t.opts.DAG)
next, err := l.GetNode(context.TODO(), t.opts.DAG)
if err != nil {
return nil, err
}
......
......@@ -52,8 +52,7 @@ func addLink(ctx context.Context, ds dag.DAGService, root *dag.Node, childname s
return nil, err
}
_, err = ds.Add(root)
if err != nil {
if _, err := ds.Add(root); err != nil {
return nil, err
}
return root, nil
......
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