From c8da8b36931a2b03cf74603ce5e284c008101918 Mon Sep 17 00:00:00 2001 From: Brian Goff Date: Tue, 23 Feb 2016 21:36:04 -0500 Subject: [PATCH] add file poller panic fix from 1.10.2 Signed-off-by: Brian Goff --- filenotify/poller.go | 3 +-- filenotify/poller_test.go | 18 ------------------ 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/filenotify/poller.go b/filenotify/poller.go index 0d92afd..5261085 100644 --- a/filenotify/poller.go +++ b/filenotify/poller.go @@ -118,8 +118,6 @@ func (w *filePoller) Close() error { w.remove(name) delete(w.watches, name) } - close(w.events) - close(w.errors) return nil } @@ -146,6 +144,7 @@ func (w *filePoller) sendErr(e error, chClose <-chan struct{}) error { // watch is responsible for polling the specified file for changes // upon finding changes to a file or errors, sendEvent/sendErr is called func (w *filePoller) watch(f *os.File, lastFi os.FileInfo, chClose chan struct{}) { + defer f.Close() for { time.Sleep(watchWaitTime) select { diff --git a/filenotify/poller_test.go b/filenotify/poller_test.go index 0715c25..4f50262 100644 --- a/filenotify/poller_test.go +++ b/filenotify/poller_test.go @@ -93,24 +93,6 @@ func TestPollerClose(t *testing.T) { t.Fatal(err) } - select { - case _, open := <-w.Events(): - if open { - t.Fatal("event chan should be closed") - } - default: - t.Fatal("event chan should be closed") - } - - select { - case _, open := <-w.Errors(): - if open { - t.Fatal("errors chan should be closed") - } - default: - t.Fatal("errors chan should be closed") - } - f, err := ioutil.TempFile("", "asdf") if err != nil { t.Fatal(err)