close the inotify watcher when returning
might fix http://bugs.activestate.com/show_bug.cgi?id=95803#c12
This commit is contained in:
parent
5c84486ca3
commit
74f84016b8
2
tail.go
2
tail.go
|
@ -76,12 +76,10 @@ func (tail *Tail) reopen(wait bool) {
|
||||||
tail.file, err = os.Open(tail.Filename)
|
tail.file, err = os.Open(tail.Filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if os.IsNotExist(err) && wait {
|
if os.IsNotExist(err) && wait {
|
||||||
log.Println("blocking until exists")
|
|
||||||
err := tail.watcher.BlockUntilExists()
|
err := tail.watcher.BlockUntilExists()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
log.Println("exists now")
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
log.Println(fmt.Sprintf("Unable to reopen file (%s): %s", tail.Filename, err))
|
log.Println(fmt.Sprintf("Unable to reopen file (%s): %s", tail.Filename, err))
|
||||||
|
|
3
watch.go
3
watch.go
|
@ -36,7 +36,7 @@ func (fw *InotifyFileWatcher) BlockUntilExists() error {
|
||||||
}
|
}
|
||||||
<-w.Event
|
<-w.Event
|
||||||
w.RemoveWatch(filepath.Dir(fw.Filename))
|
w.RemoveWatch(filepath.Dir(fw.Filename))
|
||||||
// XXX: how to free up w's goroutines without relying on the gc?
|
w.Close()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,6 +63,7 @@ func (fw *InotifyFileWatcher) ChangeEvents() chan bool {
|
||||||
case evt.IsRename():
|
case evt.IsRename():
|
||||||
close(ch)
|
close(ch)
|
||||||
w.RemoveWatch(fw.Filename)
|
w.RemoveWatch(fw.Filename)
|
||||||
|
w.Close()
|
||||||
return
|
return
|
||||||
|
|
||||||
case evt.IsModify():
|
case evt.IsModify():
|
||||||
|
|
Loading…
Reference in New Issue