From a6eb690e31e029e1b2970ff5d790de5acee3ec0d Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Mon, 23 Jun 2014 10:38:50 +0200 Subject: [PATCH 1/6] Ensure correct version string format --- cmd/syncthing/main.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmd/syncthing/main.go b/cmd/syncthing/main.go index dfbb4957d..2feb060f5 100644 --- a/cmd/syncthing/main.go +++ b/cmd/syncthing/main.go @@ -18,6 +18,7 @@ import ( "os" "os/exec" "path/filepath" + "regexp" "runtime" "runtime/debug" "runtime/pprof" @@ -48,6 +49,14 @@ var ( var l = logger.DefaultLogger func init() { + if Version != "unknown-dev" { + // If not a generic dev build, version string should come from git describe + exp := regexp.MustCompile(`^v\d+\.\d+\.\d+(-\d+-g[0-9a-f]+)?(-dirty)?$`) + if !exp.MatchString(Version) { + l.Fatalf("Invalid version string %q;\n\tdoes not match regexp %v", Version, exp) + } + } + stamp, _ := strconv.Atoi(BuildStamp) BuildDate = time.Unix(int64(stamp), 0) From e6f04ed238fb8664e9f5bbf80387ed2aaca7f1d8 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Mon, 23 Jun 2014 10:52:09 +0200 Subject: [PATCH 2/6] Don't whine about unexpected EOFs --- model/model.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/model/model.go b/model/model.go index e0ca693a5..8771fd1b3 100644 --- a/model/model.go +++ b/model/model.go @@ -370,10 +370,11 @@ func (m *Model) Close(node string, err error) { l.Debugf("%s: %v", node, err) } - if err != io.EOF { - l.Warnf("Connection to %s closed: %v", node, err) - } else if _, ok := err.(ClusterConfigMismatch); ok { + // EOFs (disconnect) are usually nothing to worry about + if err != io.EOF && err != io.ErrUnexpectedEOF { l.Warnf("Connection to %s closed: %v", node, err) + } else if debug { + l.Debugln("Connection to %s closed: %v", node, err) } cid := m.cm.Get(node) From db3e3ade80069da53ff66567a96d0f85a2fd4748 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Mon, 23 Jun 2014 11:52:13 +0200 Subject: [PATCH 3/6] No need to hold a write lock in Override --- model/model.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/model/model.go b/model/model.go index 8771fd1b3..315bb5a5a 100644 --- a/model/model.go +++ b/model/model.go @@ -858,8 +858,10 @@ func (m *Model) State(repo string) string { func (m *Model) Override(repo string) { fs := m.NeedFilesRepo(repo) - m.rmut.Lock() + m.rmut.RLock() r := m.repoFiles[repo] + m.rmut.RUnlock() + for i := range fs { f := &fs[i] h := r.Get(cid.LocalID, f.Name) @@ -873,7 +875,6 @@ func (m *Model) Override(repo string) { } f.Version = lamport.Default.Tick(f.Version) } - m.rmut.Unlock() r.Update(cid.LocalID, fs) } From 68750211ef60684014e187a68698c5339c83cd53 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Mon, 23 Jun 2014 15:06:20 +0200 Subject: [PATCH 4/6] Connection notices are informational --- cmd/syncthing/main.go | 3 +++ model/model.go | 11 +---------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/cmd/syncthing/main.go b/cmd/syncthing/main.go index 2feb060f5..0efa8afb1 100644 --- a/cmd/syncthing/main.go +++ b/cmd/syncthing/main.go @@ -703,6 +703,9 @@ next: wr = &limitedWriter{conn, rateBucket} } protoConn := protocol.NewConnection(remoteID, conn, wr, m) + + l.Infof("Connection to %s established at %v", remoteID, conn.RemoteAddr()) + m.AddConnection(conn, protoConn) continue next } diff --git a/model/model.go b/model/model.go index 315bb5a5a..7cabbcc9d 100644 --- a/model/model.go +++ b/model/model.go @@ -366,16 +366,7 @@ func (m *Model) ClusterConfig(nodeID string, config protocol.ClusterConfigMessag // Close removes the peer from the model and closes the underlying connection if possible. // Implements the protocol.Model interface. func (m *Model) Close(node string, err error) { - if debug { - l.Debugf("%s: %v", node, err) - } - - // EOFs (disconnect) are usually nothing to worry about - if err != io.EOF && err != io.ErrUnexpectedEOF { - l.Warnf("Connection to %s closed: %v", node, err) - } else if debug { - l.Debugln("Connection to %s closed: %v", node, err) - } + l.Infof("Connection to %s closed: %v", node, err) cid := m.cm.Get(node) m.rmut.RLock() From 2383579a6457ce8763e904f0f3e36fb507d0aaf4 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Mon, 23 Jun 2014 21:54:28 +0200 Subject: [PATCH 5/6] Remove spurious debug output in .stignore handling --- scanner/walk.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/scanner/walk.go b/scanner/walk.go index ec21f44e4..fff4ff359 100644 --- a/scanner/walk.go +++ b/scanner/walk.go @@ -106,7 +106,6 @@ func (w *Walker) loadIgnoreFiles(dir string, ign map[string][]string) filepath.W if pn, sn := filepath.Split(rn); sn == w.IgnoreFile { pn := filepath.Clean(pn) - l.Debugf("pn: %q", pn) bs, _ := ioutil.ReadFile(p) lines := bytes.Split(bs, []byte("\n")) var patterns []string @@ -287,7 +286,6 @@ func (w *Walker) ignoreFile(patterns map[string][]string, file string) bool { for prefix, pats := range patterns { if prefix == "." || prefix == first || strings.HasPrefix(first, fmt.Sprintf("%s%c", prefix, os.PathSeparator)) { for _, pattern := range pats { - l.Debugf("%q %q", pattern, last) if match, _ := filepath.Match(pattern, last); match { return true } From a2da31056b3ef6d619feb542552c0c82274a50eb Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Thu, 26 Jun 2014 11:24:38 +0200 Subject: [PATCH 6/6] Increase deadlock timeout, make configurable (fixes #389, fixes #393) --- cmd/syncthing/main.go | 4 +++- model/model.go | 14 +++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/cmd/syncthing/main.go b/cmd/syncthing/main.go index 0efa8afb1..d5fc32aae 100644 --- a/cmd/syncthing/main.go +++ b/cmd/syncthing/main.go @@ -115,7 +115,9 @@ The following enviroment variables are interpreted by syncthing: STCPUPROFILE Write CPU profile to the specified file. - STGUIASSETS Directory to load GUI assets from. Overrides compiled in assets.` + STGUIASSETS Directory to load GUI assets from. Overrides compiled in assets. + + STDEADLOCKTIMEOUT Alter deadlock detection timeout (seconds; default 1200).` ) func init() { diff --git a/model/model.go b/model/model.go index 7cabbcc9d..a05de8afd 100644 --- a/model/model.go +++ b/model/model.go @@ -13,6 +13,7 @@ import ( "net" "os" "path/filepath" + "strconv" "sync" "time" @@ -97,9 +98,16 @@ func NewModel(indexDir string, cfg *config.Configuration, clientName, clientVers sup: suppressor{threshold: int64(cfg.Options.MaxChangeKbps)}, } - deadlockDetect(&m.rmut, 60*time.Second) - deadlockDetect(&m.smut, 60*time.Second) - deadlockDetect(&m.pmut, 60*time.Second) + 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.rmut, time.Duration(timeout)*time.Second) + deadlockDetect(&m.smut, time.Duration(timeout)*time.Second) + deadlockDetect(&m.pmut, time.Duration(timeout)*time.Second) go m.broadcastIndexLoop() return m }