git.iko.soy/typeable/oauth2-proxy
on master help sign in
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.

commitc3590b5c4cf49cfee3919032917467c6f24b34a2 authorMike Bland <mbland@acm.org> dateSat 30 May 2015, 22:02 (11 years ago) parent577a3f7
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}