fix goroutine leak in Editor/Downloader

parent d4db80ef
......@@ -178,10 +178,12 @@ func NewDownloader(host modules.HostDBEntry, contract modules.RenterContract, hd
defer extendDeadline(conn, time.Hour)
if err := encoding.WriteObject(conn, modules.RPCDownload); err != nil {
conn.Close()
close(closeChan)
return nil, errors.New("couldn't initiate RPC: " + err.Error())
}
if err := verifyRecentRevision(conn, contract, host.Version); err != nil {
conn.Close() // TODO: close gracefully if host has entered revision loop
close(closeChan)
return nil, err
}
......
......@@ -304,10 +304,12 @@ func NewEditor(host modules.HostDBEntry, contract modules.RenterContract, curren
defer extendDeadline(conn, time.Hour)
if err := encoding.WriteObject(conn, modules.RPCReviseContract); err != nil {
conn.Close()
close(closeChan)
return nil, errors.New("couldn't initiate RPC: " + err.Error())
}
if err := verifyRecentRevision(conn, contract, host.Version); err != nil {
conn.Close() // TODO: close gracefully if host has entered revision loop
close(closeChan)
return nil, err
}
......
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