Merge "veyron/services/mgmt/suidhelper/impl/*: ignore system uids"
diff --git a/services/config/lib/config.go b/services/config/lib/config.go
index 3ab82c6..f98a9a3 100644
--- a/services/config/lib/config.go
+++ b/services/config/lib/config.go
@@ -33,7 +33,6 @@
type configService struct {
rwlock sync.RWMutex // protects elements of this structure.
- atomic sync.RWMutex // ties together setting config below and writing the file.
mdns *mdns.MDNS
service string
file string // file containing config
@@ -289,14 +288,11 @@
cs.rwlock.Unlock()
continue
}
- // This lock is to tie setting the data structure and writing the file into an atomic operation.
- cs.atomic.Lock()
cs.current = config
cs.gen++
cs.change.Broadcast()
- cs.rwlock.Unlock()
writeFile(cs.file, cs.current)
- cs.atomic.Unlock()
+ cs.rwlock.Unlock()
cs.Offer()
case <-cs.done:
return
@@ -377,17 +373,17 @@
// Reread the config file and remember it if the version is newer than current.
func (cs *configService) Reread() error {
- cs.rwlock.RLock()
+ cs.rwlock.Lock()
file := cs.file
- cs.rwlock.RUnlock()
if len(file) == 0 {
+ cs.rwlock.Unlock()
return nil
}
c, err := readFile(file)
if err != nil {
+ cs.rwlock.Unlock()
return err
}
- cs.rwlock.Lock()
if cs.current != nil && c.version <= cs.current.version {
cs.rwlock.Unlock()
return nil
diff --git a/services/config/lib/config_test.go b/services/config/lib/config_test.go
index ea6a939..37a69f9 100644
--- a/services/config/lib/config_test.go
+++ b/services/config/lib/config_test.go
@@ -85,7 +85,7 @@
func waitForConsistency(cs ConfigService, ref map[string]string) error {
finalerr := errors.New("inconsistent")
- for loops := 0; loops < 20; loops++ {
+ for loops := 0; loops < 30; loops++ {
actual, err := cs.GetAll()
if err == nil {
err := compare(actual, ref)
@@ -96,7 +96,7 @@
}
time.Sleep(500 * time.Millisecond)
}
- return finalerr
+ return errors.New("timeout waiting for consistency: " + finalerr.Error())
}
func testConfig(fileA, fileB, fileD string) error {