Add mutex logging

This commit is contained in:
Audrius Butkevicius
2015-04-22 23:54:31 +01:00
parent 9ee3541655
commit 433b923ea7
31 changed files with 277 additions and 78 deletions

View File

@@ -17,11 +17,11 @@ import (
"bytes"
"encoding/binary"
"sort"
"sync"
"github.com/syncthing/protocol"
"github.com/syncthing/syncthing/internal/config"
"github.com/syncthing/syncthing/internal/osutil"
"github.com/syncthing/syncthing/internal/sync"
"github.com/syndtr/goleveldb/leveldb"
"github.com/syndtr/goleveldb/leveldb/util"
@@ -123,7 +123,8 @@ func NewBlockFinder(db *leveldb.DB, cfg *config.Wrapper) *BlockFinder {
}
f := &BlockFinder{
db: db,
db: db,
mut: sync.NewRWMutex(),
}
f.Changed(cfg.Raw())
cfg.Subscribe(f)

View File

@@ -10,10 +10,11 @@ import (
"crypto/rand"
"log"
"os"
"sync"
"testing"
"time"
"github.com/syncthing/syncthing/internal/sync"
"github.com/syndtr/goleveldb/leveldb"
"github.com/syndtr/goleveldb/leveldb/opt"
"github.com/syndtr/goleveldb/leveldb/util"
@@ -132,7 +133,7 @@ func TestConcurrentSetClear(t *testing.T) {
dur := 30 * time.Second
t0 := time.Now()
var wg sync.WaitGroup
wg := sync.NewWaitGroup()
os.RemoveAll("testdata/concurrent-set-clear.db")
db, err := leveldb.OpenFile("testdata/concurrent-set-clear.db", &opt.Options{OpenFilesCacheCapacity: 10})
@@ -188,7 +189,7 @@ func TestConcurrentSetOnly(t *testing.T) {
dur := 30 * time.Second
t0 := time.Now()
var wg sync.WaitGroup
wg := sync.NewWaitGroup()
os.RemoveAll("testdata/concurrent-set-only.db")
db, err := leveldb.OpenFile("testdata/concurrent-set-only.db", &opt.Options{OpenFilesCacheCapacity: 10})

View File

@@ -14,9 +14,9 @@ import (
"fmt"
"runtime"
"sort"
"sync"
"github.com/syncthing/protocol"
"github.com/syncthing/syncthing/internal/sync"
"github.com/syndtr/goleveldb/leveldb"
"github.com/syndtr/goleveldb/leveldb/iterator"
"github.com/syndtr/goleveldb/leveldb/opt"
@@ -25,7 +25,7 @@ import (
var (
clockTick int64
clockMut sync.Mutex
clockMut sync.Mutex = sync.NewMutex()
)
func clock(v int64) int64 {

View File

@@ -13,10 +13,9 @@
package db
import (
"sync"
"github.com/syncthing/protocol"
"github.com/syncthing/syncthing/internal/osutil"
"github.com/syncthing/syncthing/internal/sync"
"github.com/syndtr/goleveldb/leveldb"
)
@@ -50,6 +49,7 @@ func NewFileSet(folder string, db *leveldb.DB) *FileSet {
folder: folder,
db: db,
blockmap: NewBlockMap(db, folder),
mutex: sync.NewMutex(),
}
ldbCheckGlobals(db, []byte(folder))