Commit b569ecdd authored by Luke Champine's avatar Luke Champine Committed by GitHub

Merge pull request #2129 from NebulousLabs/deadlock

fix deadlock in renter
parents 6f114db1 37b104b9
......@@ -371,8 +371,9 @@ func (r *Renter) managedDownloadIteration(ds *downloadState) {
}
// Update the set of workers to include everyone in the worker pool.
contracts := r.hostContractor.Contracts()
id := r.mu.Lock()
r.updateWorkerPool()
r.updateWorkerPool(contracts)
ds.availableWorkers = make([]*worker, 0, len(r.workerPool))
for _, worker := range r.workerPool {
// Ignore workers that are already in the active set of workers.
......
......@@ -214,7 +214,8 @@ func newRenter(cs modules.ConsensusSet, tpool modules.TransactionPool, hdb hostD
}
// Spin up the workers for the work pool.
r.updateWorkerPool()
contracts := r.hostContractor.Contracts()
r.updateWorkerPool(contracts)
go r.threadedRepairLoop()
go r.threadedDownloadLoop()
go r.threadedQueueRepairs()
......@@ -302,8 +303,9 @@ func (r *Renter) SetSettings(s modules.RenterSettings) error {
return err
}
contracts := r.hostContractor.Contracts()
id := r.mu.Lock()
r.updateWorkerPool()
r.updateWorkerPool(contracts)
r.mu.Unlock(id)
return nil
}
......
......@@ -196,8 +196,9 @@ func (r *Renter) managedRepairIteration(rs *repairState) {
}
// Reset the available workers.
contracts := r.hostContractor.Contracts()
id := r.mu.Lock()
r.updateWorkerPool()
r.updateWorkerPool(contracts)
rs.availableWorkers = make(map[types.FileContractID]*worker)
for id, worker := range r.workerPool {
// Ignore the workers that are not good for uploading.
......
......@@ -228,10 +228,10 @@ func (w *worker) threadedWorkLoop() {
// updateWorkerPool will grab the set of contracts from the contractor and
// update the worker pool to match.
func (r *Renter) updateWorkerPool() {
func (r *Renter) updateWorkerPool(contracts []modules.RenterContract) {
// Get a map of all the contracts in the contractor.
newContracts := make(map[types.FileContractID]modules.RenterContract)
for _, nc := range r.hostContractor.Contracts() {
for _, nc := range contracts {
newContracts[nc.ID] = nc
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment