mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-22 19:08:58 +00:00
Only run deadlock detection if asked or non-release/beta (fixes #1536)
This commit is contained in:
parent
a892f80e86
commit
df6dbc5fa4
@ -50,6 +50,7 @@ var (
|
|||||||
BuildHost = "unknown"
|
BuildHost = "unknown"
|
||||||
BuildUser = "unknown"
|
BuildUser = "unknown"
|
||||||
IsRelease bool
|
IsRelease bool
|
||||||
|
IsBeta bool
|
||||||
LongVersion string
|
LongVersion string
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -80,6 +81,7 @@ func init() {
|
|||||||
// Check for a clean release build.
|
// Check for a clean release build.
|
||||||
exp := regexp.MustCompile(`^v\d+\.\d+\.\d+(-beta[\d\.]+)?$`)
|
exp := regexp.MustCompile(`^v\d+\.\d+\.\d+(-beta[\d\.]+)?$`)
|
||||||
IsRelease = exp.MatchString(Version)
|
IsRelease = exp.MatchString(Version)
|
||||||
|
IsBeta = strings.Contains(Version, "beta")
|
||||||
|
|
||||||
stamp, _ := strconv.Atoi(BuildStamp)
|
stamp, _ := strconv.Atoi(BuildStamp)
|
||||||
BuildDate = time.Unix(int64(stamp), 0)
|
BuildDate = time.Unix(int64(stamp), 0)
|
||||||
@ -510,6 +512,15 @@ func syncthingMain() {
|
|||||||
|
|
||||||
m := model.NewModel(cfg, myID, myName, "syncthing", Version, ldb)
|
m := model.NewModel(cfg, myID, myName, "syncthing", Version, ldb)
|
||||||
|
|
||||||
|
if t := os.Getenv("STDEADLOCKTIMEOUT"); len(t) > 0 {
|
||||||
|
it, err := strconv.Atoi(t)
|
||||||
|
if err == nil {
|
||||||
|
m.StartDeadlockDetector(time.Duration(it) * time.Second)
|
||||||
|
}
|
||||||
|
} else if !IsRelease || IsBeta {
|
||||||
|
m.StartDeadlockDetector(20 * 60 * time.Second)
|
||||||
|
}
|
||||||
|
|
||||||
// GUI
|
// GUI
|
||||||
|
|
||||||
setupGUI(cfg, m)
|
setupGUI(cfg, m)
|
||||||
|
@ -17,7 +17,6 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@ -118,18 +117,17 @@ func NewModel(cfg *config.Wrapper, id protocol.DeviceID, deviceName, clientName,
|
|||||||
go m.progressEmitter.Serve()
|
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
|
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
|
// 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
|
// read/write mode the model will attempt to keep in sync with the cluster by
|
||||||
// pulling needed files from peer devices.
|
// pulling needed files from peer devices.
|
||||||
|
Loading…
Reference in New Issue
Block a user