Fix validator_test hang on Solaris, Plan 9
On these platforms, the `done <- true` statement in during TearDown() was hanging, since the `watcher_unsupported.go` version was never draining the channel. Also took the opportunity to update the WatchForUpdates() signature to not return bool anymore.
This commit is contained in:
parent
577a3f7f09
commit
c3590b5c4c
@ -21,13 +21,10 @@ func NewUserMap(usersFile string, done <-chan bool, onUpdate func()) *UserMap {
|
|||||||
atomic.StorePointer(&um.m, unsafe.Pointer(&m))
|
atomic.StorePointer(&um.m, unsafe.Pointer(&m))
|
||||||
if usersFile != "" {
|
if usersFile != "" {
|
||||||
log.Printf("using authenticated emails file %s", usersFile)
|
log.Printf("using authenticated emails file %s", usersFile)
|
||||||
started := WatchForUpdates(usersFile, done, func() {
|
WatchForUpdates(usersFile, done, func() {
|
||||||
um.LoadAuthenticatedEmailsFile()
|
um.LoadAuthenticatedEmailsFile()
|
||||||
onUpdate()
|
onUpdate()
|
||||||
})
|
})
|
||||||
if started {
|
|
||||||
log.Printf("watching %s for updates", usersFile)
|
|
||||||
}
|
|
||||||
um.LoadAuthenticatedEmailsFile()
|
um.LoadAuthenticatedEmailsFile()
|
||||||
}
|
}
|
||||||
return um
|
return um
|
||||||
|
@ -30,7 +30,7 @@ func WaitForReplacement(filename string, op fsnotify.Op,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func WatchForUpdates(filename string, done <-chan bool, action func()) bool {
|
func WatchForUpdates(filename string, done <-chan bool, action func()) {
|
||||||
filename = filepath.Clean(filename)
|
filename = filepath.Clean(filename)
|
||||||
watcher, err := fsnotify.NewWatcher()
|
watcher, err := fsnotify.NewWatcher()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -65,5 +65,5 @@ func WatchForUpdates(filename string, done <-chan bool, action func()) bool {
|
|||||||
if err = watcher.Add(filename); err != nil {
|
if err = watcher.Add(filename); err != nil {
|
||||||
log.Fatal("failed to add ", filename, " to watcher: ", err)
|
log.Fatal("failed to add ", filename, " to watcher: ", err)
|
||||||
}
|
}
|
||||||
return true
|
log.Printf("watching %s for updates", filename)
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func WatchForUpdates(filename string, done <-chan bool, action func()) bool {
|
func WatchForUpdates(filename string, done <-chan bool, action func()) {
|
||||||
log.Printf("file watching not implemented on this platform")
|
log.Printf("file watching not implemented on this platform")
|
||||||
return false
|
go func() { <-done }()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user