Skip to content

Commit

Permalink
Merge pull request ipfs#21 from ipfs/fix/fetch-deadlock
Browse files Browse the repository at this point in the history
fix a fetch deadlock on error
  • Loading branch information
Stebalien committed Nov 28, 2018
2 parents ff7c070 + 3b8c0ad commit 53eb8d0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion merkledag.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,10 @@ func EnumerateChildrenAsyncDepth(ctx context.Context, getLinks GetLinks, c cid.C
if shouldVisit {
links, err := getLinks(ctx, ci)
if err != nil {
errChan <- err
select {
case errChan <- err:
case <-fetchersCtx.Done():
}
return
}

Expand Down
5 changes: 5 additions & 0 deletions merkledag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,7 @@ func TestEnumerateAsyncFailsNotFound(t *testing.T) {
b := NodeWithData([]byte("foo2"))
c := NodeWithData([]byte("foo3"))
d := NodeWithData([]byte("foo4"))
e := NodeWithData([]byte("foo5"))

ds := dstest.Mock()
for _, n := range []ipld.Node{a, b, c} {
Expand All @@ -703,6 +704,10 @@ func TestEnumerateAsyncFailsNotFound(t *testing.T) {
t.Fatal(err)
}

if err := parent.AddNodeLink("e", e); err != nil {
t.Fatal(err)
}

err := ds.Add(ctx, parent)
if err != nil {
t.Fatal(err)
Expand Down

0 comments on commit 53eb8d0

Please sign in to comment.