Add RwMutexes to all collections. #116

This commit is contained in:
Andrey Smirnov
2014-10-08 16:16:07 +04:00
parent 2ed76f1e4c
commit ac983ff65d
4 changed files with 20 additions and 8 deletions
+4 -1
View File
@@ -16,6 +16,7 @@ import (
"path/filepath"
"strconv"
"strings"
"sync"
"syscall"
"time"
)
@@ -593,6 +594,7 @@ func (repo *RemoteRepo) RefKey() []byte {
// RemoteRepoCollection does listing, updating/adding/deleting of RemoteRepos
type RemoteRepoCollection struct {
*sync.RWMutex
db database.Storage
list []*RemoteRepo
}
@@ -600,7 +602,8 @@ type RemoteRepoCollection struct {
// NewRemoteRepoCollection loads RemoteRepos from DB and makes up collection
func NewRemoteRepoCollection(db database.Storage) *RemoteRepoCollection {
result := &RemoteRepoCollection{
db: db,
RWMutex: &sync.RWMutex{},
db: db,
}
blobs := db.FetchByPrefix([]byte("R"))