This commit is contained in:
Benoit Verkindt 2017-11-30 10:43:20 +00:00 committed by GitHub
commit 3bc264f8a0

View file

@ -43,11 +43,14 @@ type chunkerTester struct {
inputs map[uint64][]byte
chunks map[string]*Chunk
t test
lock sync.Mutex
}
func (self *chunkerTester) Split(chunker Splitter, data io.Reader, size int64, chunkC chan *Chunk, swg *sync.WaitGroup, expectedError error) (key Key, err error) {
// reset
self.lock.Lock()
self.chunks = make(map[string]*Chunk)
self.lock.Unlock()
if self.inputs == nil {
self.inputs = make(map[uint64][]byte)
@ -65,7 +68,9 @@ func (self *chunkerTester) Split(chunker Splitter, data io.Reader, size int64, c
return nil
case chunk := <-chunkC:
// self.chunks = append(self.chunks, chunk)
self.lock.Lock()
self.chunks[chunk.Key.String()] = chunk
self.lock.Unlock()
if chunk.wg != nil {
chunk.wg.Done()
}
@ -81,9 +86,6 @@ func (self *chunkerTester) Split(chunker Splitter, data io.Reader, size int64, c
}
if chunkC != nil {
if swg != nil {
swg.Wait()
}
close(quitC)
}
return key, err