瀏覽代碼

lib/sync: Fix broken build

Audrius Butkevicius 9 年之前
父節點
當前提交
caaab462bc
共有 2 個文件被更改,包括 7 次插入4 次删除
  1. 5 2
      lib/sync/debug.go
  2. 2 2
      lib/sync/sync.go

+ 5 - 2
lib/sync/debug.go

@@ -12,8 +12,8 @@ import (
 	"strings"
 	"time"
 
-	"github.com/syncthing/syncthing/lib/logger"
 	"github.com/sasha-s/go-deadlock"
+	"github.com/syncthing/syncthing/lib/logger"
 )
 
 var (
@@ -31,7 +31,10 @@ func init() {
 	l.SetDebug("sync", strings.Contains(os.Getenv("STTRACE"), "sync") || os.Getenv("STTRACE") == "all")
 
 	if n, err := strconv.Atoi(os.Getenv("STLOCKTHRESHOLD")); err == nil {
-		deadlock.Opts.DeadlockTimeout = threshold = time.Duration(n) * time.Millisecond
+		threshold = time.Duration(n) * time.Millisecond
+	}
+	if n, err := strconv.Atoi(os.Getenv("STDEADLOCK")); err == nil {
+		deadlock.Opts.DeadlockTimeout = time.Duration(n) * time.Second
 	}
 	l.Debugf("Enabling lock logging at %v threshold", threshold)
 }

+ 2 - 2
lib/sync/sync.go

@@ -38,7 +38,7 @@ type WaitGroup interface {
 
 func NewMutex() Mutex {
 	if useDeadlock {
-		return deadlock.Mutex{}
+		return &deadlock.Mutex{}
 	}
 	if debug {
 		mutex := &loggedMutex{}
@@ -50,7 +50,7 @@ func NewMutex() Mutex {
 
 func NewRWMutex() RWMutex {
 	if useDeadlock {
-		return deadlock.RWMutex{}
+		return &deadlock.RWMutex{}
 	}
 	if debug {
 		mutex := &loggedRWMutex{