Skip to content

Commit

Permalink
renterutil: Delete HostSet map on Close
Browse files Browse the repository at this point in the history
This was causing a deadlock when Close was called twice, since Close
permanently locks the session mutexes.
  • Loading branch information
lukechampine committed Jul 31, 2019
1 parent 9783369 commit 2e46f7c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions renter/renterutil/hostset.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ type HostSet struct {

// Close closes all of the sessions in the set.
func (set *HostSet) Close() error {
for _, lh := range set.sessions {
for hostKey, lh := range set.sessions {
lh.mu.Lock()
if lh.s != nil {
lh.s.Close()
lh.s = nil
}
delete(set.sessions, hostKey)
}
return nil
}
Expand Down Expand Up @@ -159,9 +160,7 @@ func DownloadChunkShards(hosts []*renter.ShardDownloader, chunkIndex int64, minS
if len(goodRes) < minShards {
var errStrings []string
for _, r := range badRes {
if r.err != errNoHost {
errStrings = append(errStrings, r.err.Error())
}
errStrings = append(errStrings, r.err.Error())
}
return nil, 0, errors.New("too many hosts did not supply their shard:\n" + strings.Join(errStrings, "\n"))
}
Expand Down

0 comments on commit 2e46f7c

Please sign in to comment.