git.iko.soy/typeable/oauth2-proxy
on master help sign in
Merge pull request #107 from 18F/fix-validator-test

Fix validator_test hang on Solaris, Plan 9

commit71b79baf3331ff03646b7a367b98d381ed6c1120 authorJehiah Czebotar <jehiah@gmail.com> dateSun 31 May 2015, 00:06 (11 years ago) parent577a3f7c3590b5
3 files changed+5−8
validator.go+1−4 watcher.go+2−2 watcher_unsupported.go+2−2
validator.go+1−4
@@ -21,13 +21,10 @@ func NewUserMap(usersFile string, done <-chan bool, onUpdate func()) *UserMap {
2121 atomic.StorePointer(&um.m, unsafe.Pointer(&m))
2222 if usersFile != "" {
2323 log.Printf("using authenticated emails file %s", usersFile)
24− started := WatchForUpdates(usersFile, done, func() {
24+ WatchForUpdates(usersFile, done, func() {
2525 um.LoadAuthenticatedEmailsFile()
2626 onUpdate()
2727 })
28− if started {
29− log.Printf("watching %s for updates", usersFile)
30− }
3128 um.LoadAuthenticatedEmailsFile()
3229 }
3330 return um
watcher.go+2−2
@@ -30,7 +30,7 @@ func WaitForReplacement(filename string, op fsnotify.Op,
3030 }
3131}
3232
33−func WatchForUpdates(filename string, done <-chan bool, action func()) bool {
33+func WatchForUpdates(filename string, done <-chan bool, action func()) {
3434 filename = filepath.Clean(filename)
3535 watcher, err := fsnotify.NewWatcher()
3636 if err != nil {
@@ -65,5 +65,5 @@ func WatchForUpdates(filename string, done <-chan bool, action func()) bool {
6565 if err = watcher.Add(filename); err != nil {
6666 log.Fatal("failed to add ", filename, " to watcher: ", err)
6767 }
68− return true
68+ log.Printf("watching %s for updates", filename)
6969}
watcher_unsupported.go+2−2
@@ -6,7 +6,7 @@ import (
66 "log"
77)
88
9−func WatchForUpdates(filename string, done <-chan bool, action func()) bool {
9+func WatchForUpdates(filename string, done <-chan bool, action func()) {
1010 log.Printf("file watching not implemented on this platform")
11− return false
11+ go func() { <-done }()
1212}