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

Merge pull request #2130 from NebulousLabs/deadlock

Small tweaks
parents b569ecdd 965dc031
......@@ -200,6 +200,12 @@ func (api *API) parseHostSettings(req *http.Request) (modules.HostInternalSettin
// hostEstimateScoreGET handles the POST request to /host/estimatescore and
// computes an estimated HostDB score for the provided settings.
func (api *API) hostEstimateScoreGET(w http.ResponseWriter, req *http.Request, _ httprouter.Params) {
// This call requires a renter, check that it is present.
if api.renter == nil {
WriteError(w, Error{"cannot call /host/estimatescore without the renter module"}, http.StatusBadRequest)
return
}
settings, err := api.parseHostSettings(req)
if err != nil {
WriteError(w, Error{"error parsing host settings: " + err.Error()}, http.StatusBadRequest)
......
......@@ -173,8 +173,8 @@ func (he *hostEditor) Modify(oldRoot, newRoot crypto.Hash, offset uint64, newDat
// Editor returns a Editor object that can be used to upload, modify, and
// delete sectors on a host.
func (c *Contractor) Editor(id types.FileContractID, cancel <-chan struct{}) (_ Editor, err error) {
c.mu.RLock()
id = c.ResolveID(id)
c.mu.RLock()
cachedEditor, haveEditor := c.editors[id]
height := c.blockHeight
contract, haveContract := c.contracts[id]
......
......@@ -187,7 +187,6 @@ func (r *Renter) managedRepairIteration(rs *repairState) {
case <-r.tg.StopChan():
return
case file := <-r.newRepairs:
// TODO: This seems to be happening out of lock, investigate.
id := r.mu.Lock()
r.addFileToRepairState(rs, file)
r.mu.Unlock(id)
......
......@@ -141,14 +141,16 @@ func (w *worker) upload(uw uploadWork) {
w.consecutiveUploadFailures = 0
// Update the renter metadata.
addr := e.Address()
endHeight := e.EndHeight()
id := w.renter.mu.Lock()
uw.file.mu.Lock()
contract, exists := uw.file.contracts[w.contractID]
if !exists {
contract = fileContract{
ID: w.contractID,
IP: e.Address(),
WindowStart: e.EndHeight(),
IP: addr,
WindowStart: endHeight,
}
}
contract.Pieces = append(contract.Pieces, pieceData{
......
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