diff --git a/cmd/syncthing/main.go b/cmd/syncthing/main.go index 90ed07226..a6c344d87 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) @@ -106,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() { @@ -694,6 +705,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 6e78a30c9..ecb1ffab8 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 } @@ -366,15 +374,7 @@ func (m *Model) ClusterConfig(nodeID protocol.NodeID, config protocol.ClusterCon // Close removes the peer from the model and closes the underlying connection if possible. // Implements the protocol.Model interface. func (m *Model) Close(node protocol.NodeID, err error) { - if debug { - 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 { - l.Warnf("Connection to %s closed: %v", node, err) - } + l.Infof("Connection to %s closed: %v", node, err) cid := m.cm.Get(node) m.rmut.RLock() @@ -857,8 +857,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) @@ -872,7 +874,6 @@ func (m *Model) Override(repo string) { } f.Version = lamport.Default.Tick(f.Version) } - m.rmut.Unlock() r.Update(cid.LocalID, fs) } 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 }