Skip to content

Commit 33107f3

Browse files
author
Nino Kodabande
authored
Merge pull request hpcloud#100 from bahlo/cleanup-error
Return error on tail.Cleanup
2 parents 46ed7f0 + 9c97d75 commit 33107f3

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

watch/inotify_tracker.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,21 +83,21 @@ func watch(winfo *watchInfo) error {
8383
}
8484

8585
// RemoveWatch signals the run goroutine to remove the watch for the input filename
86-
func RemoveWatch(fname string) {
87-
remove(&watchInfo{
86+
func RemoveWatch(fname string) error {
87+
return remove(&watchInfo{
8888
fname: fname,
8989
})
9090
}
9191

9292
// RemoveWatch create signals the run goroutine to remove the watch for the input filename
93-
func RemoveWatchCreate(fname string) {
94-
remove(&watchInfo{
93+
func RemoveWatchCreate(fname string) error {
94+
return remove(&watchInfo{
9595
op: fsnotify.Create,
9696
fname: fname,
9797
})
9898
}
9999

100-
func remove(winfo *watchInfo) {
100+
func remove(winfo *watchInfo) error {
101101
// start running the shared InotifyTracker if not already running
102102
once.Do(goRun)
103103

@@ -126,9 +126,10 @@ func remove(winfo *watchInfo) {
126126
// synchronously for the kernel to acknowledge the removal of the watch
127127
// for this file, which causes us to deadlock if we still held the lock.
128128
if watchNum == 0 {
129-
shared.watcher.Remove(fname)
129+
return shared.watcher.Remove(fname)
130130
}
131131
shared.remove <- winfo
132+
return nil
132133
}
133134

134135
// Events returns a channel to which FileEvents corresponding to the input filename
@@ -142,8 +143,8 @@ func Events(fname string) <-chan fsnotify.Event {
142143
}
143144

144145
// Cleanup removes the watch for the input filename if necessary.
145-
func Cleanup(fname string) {
146-
RemoveWatch(fname)
146+
func Cleanup(fname string) error {
147+
return RemoveWatch(fname)
147148
}
148149

149150
// watchFlags calls fsnotify.WatchFlags for the input filename and flags, creating

0 commit comments

Comments
 (0)