Only run deadlock detection if asked or non-release/beta (fixes #1536)

This commit is contained in:
Audrius Butkevicius
2015-04-08 13:35:03 +01:00
parent a892f80e86
commit df6dbc5fa4
2 changed files with 19 additions and 10 deletions

View File

@@ -17,7 +17,6 @@ import (
"net"
"os"
"path/filepath"
"strconv"
"strings"
"sync"
"time"
@@ -118,18 +117,17 @@ func NewModel(cfg *config.Wrapper, id protocol.DeviceID, deviceName, clientName,
go m.progressEmitter.Serve()
}
var timeout = 20 * 60 // seconds
if t := os.Getenv("STDEADLOCKTIMEOUT"); len(t) > 0 {
it, err := strconv.Atoi(t)
if err == nil {
timeout = it
}
}
deadlockDetect(&m.fmut, time.Duration(timeout)*time.Second)
deadlockDetect(&m.pmut, time.Duration(timeout)*time.Second)
return m
}
// Starts deadlock detector on the models locks which causes panics in case
// the locks cannot be acquired in the given timeout period.
func (m *Model) StartDeadlockDetector(timeout time.Duration) {
l.Infof("Starting deadlock detector with %v timeout", timeout)
deadlockDetect(&m.fmut, timeout)
deadlockDetect(&m.pmut, timeout)
}
// StartRW starts read/write processing on the current model. When in
// read/write mode the model will attempt to keep in sync with the cluster by
// pulling needed files from peer devices.