Data race: can't access sharedPullerState.closed from the outside

This commit is contained in:
Jakob Borg 2014-11-29 23:18:56 +01:00
parent 577aaf8ad6
commit 42b8dafafe

View File

@ -743,15 +743,6 @@ nextBlock:
} }
func (p *Puller) performFinish(state *sharedPullerState) { func (p *Puller) performFinish(state *sharedPullerState) {
if closed, err := state.finalClose(); closed {
if debug {
l.Debugln(p, "closing", state.file.Name)
}
if err != nil {
l.Warnln("puller: final:", err)
return
}
// Verify the file against expected hashes // Verify the file against expected hashes
fd, err := os.Open(state.tempName) fd, err := os.Open(state.tempName)
if err != nil { if err != nil {
@ -836,18 +827,26 @@ func (p *Puller) performFinish(state *sharedPullerState) {
// Record the updated file in the index // Record the updated file in the index
p.model.updateLocal(p.folder, state.file) p.model.updateLocal(p.folder, state.file)
}
} }
func (p *Puller) finisherRoutine(in <-chan *sharedPullerState) { func (p *Puller) finisherRoutine(in <-chan *sharedPullerState) {
for state := range in { for state := range in {
if closed, err := state.finalClose(); closed {
if debug {
l.Debugln(p, "closing", state.file.Name)
}
if err != nil {
l.Warnln("puller: final:", err)
continue
}
p.performFinish(state) p.performFinish(state)
if state.closed && p.progressEmitter != nil { if p.progressEmitter != nil {
p.progressEmitter.Deregister(state) p.progressEmitter.Deregister(state)
} }
} }
} }
}
// clean deletes orphaned temporary files // clean deletes orphaned temporary files
func (p *Puller) clean() { func (p *Puller) clean() {