mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 16:34:30 +01:00
cmd: shorten the locking window when using --progress to avoid deadlock
Before this change, using -P occasionally deadlocked on the progress mutex and the stats mutex since they call each other. This is fixed by shortening the locking window in the progress routine so as not to include the stats calculation.
This commit is contained in:
parent
d377842395
commit
fdef567da6
@ -84,9 +84,6 @@ var (
|
||||
|
||||
// printProgress prints the progress with an optional log
|
||||
func printProgress(logMessage string) {
|
||||
progressMu.Lock()
|
||||
defer progressMu.Unlock()
|
||||
|
||||
var buf bytes.Buffer
|
||||
w, h, err := terminal.GetSize(int(os.Stdout.Fd()))
|
||||
if err != nil {
|
||||
@ -100,6 +97,10 @@ func printProgress(logMessage string) {
|
||||
buf.WriteString(s)
|
||||
}
|
||||
|
||||
// Lock from here to prevent terminal corruption
|
||||
progressMu.Lock()
|
||||
progressMu.Unlock()
|
||||
|
||||
if logMessage != "" {
|
||||
out("\n")
|
||||
out(moveUp)
|
||||
|
Loading…
Reference in New Issue
Block a user