Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swarm/storage: fix HashExplore concurrency bug ethersphere#1211 #19028

Merged
merged 5 commits into from
Feb 12, 2019
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions swarm/storage/filestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"io"
"sort"
"sync"
)

/*
Expand Down Expand Up @@ -123,6 +124,7 @@ func (f *FileStore) GetAllReferences(ctx context.Context, data io.Reader, toEncr
type HashExplorer struct {
*hasherStore
References []Reference
holisticode marked this conversation as resolved.
Show resolved Hide resolved
lock sync.RWMutex
holisticode marked this conversation as resolved.
Show resolved Hide resolved
}

// HashExplorer's Put will add just the chunk hashes to its `References`
Expand All @@ -133,6 +135,8 @@ func (he *HashExplorer) Put(ctx context.Context, chunkData ChunkData) (Reference
return nil, err
}
// internally store the reference
he.lock.Lock()
he.References = append(he.References, ref)
he.lock.Unlock()
return ref, nil
}