From 74f84016b8d950a3eff868fc941f3e5a93d1ea8b Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Fri, 12 Oct 2012 07:09:36 -0700 Subject: [PATCH] close the inotify watcher when returning might fix http://bugs.activestate.com/show_bug.cgi?id=95803#c12 --- tail.go | 2 -- watch.go | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/tail.go b/tail.go index 172a056..3bda8a1 100644 --- a/tail.go +++ b/tail.go @@ -76,12 +76,10 @@ func (tail *Tail) reopen(wait bool) { tail.file, err = os.Open(tail.Filename) if err != nil { if os.IsNotExist(err) && wait { - log.Println("blocking until exists") err := tail.watcher.BlockUntilExists() if err != nil { panic(err) } - log.Println("exists now") continue } log.Println(fmt.Sprintf("Unable to reopen file (%s): %s", tail.Filename, err)) diff --git a/watch.go b/watch.go index 24ec164..714d2fb 100644 --- a/watch.go +++ b/watch.go @@ -36,7 +36,7 @@ func (fw *InotifyFileWatcher) BlockUntilExists() error { } <-w.Event w.RemoveWatch(filepath.Dir(fw.Filename)) - // XXX: how to free up w's goroutines without relying on the gc? + w.Close() return nil } @@ -63,6 +63,7 @@ func (fw *InotifyFileWatcher) ChangeEvents() chan bool { case evt.IsRename(): close(ch) w.RemoveWatch(fw.Filename) + w.Close() return case evt.IsModify():