Skip to content
This repository was archived by the owner on Jan 24, 2019. It is now read-only.

Commit c3590b5

Browse files
committed
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.
1 parent 577a3f7 commit c3590b5

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

validator.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -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
Original file line numberDiff line numberDiff line change
@@ -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
Original file line numberDiff line numberDiff line change
@@ -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
}

0 commit comments

Comments
 (0)