From 2251e5db3ff66ce56889237c299e2e0c1a699698 Mon Sep 17 00:00:00 2001 From: Alexander Morozov Date: Fri, 19 Feb 2016 14:37:33 -0800 Subject: [PATCH] filenotify: don't close channels to avoid panic Signed-off-by: Alexander Morozov --- pkg/filenotify/poller.go | 6 ++++-- pkg/filenotify/poller_test.go | 18 ------------------ 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/pkg/filenotify/poller.go b/pkg/filenotify/poller.go index 0d92afd4cb..0ab4338617 100644 --- a/pkg/filenotify/poller.go +++ b/pkg/filenotify/poller.go @@ -118,8 +118,10 @@ func (w *filePoller) Close() error { w.remove(name) delete(w.watches, name) } - close(w.events) - close(w.errors) + // channels will be closed by GC, we don't do it to avoid panic in send + // functions + // close(w.events) + // close(w.errors) return nil } diff --git a/pkg/filenotify/poller_test.go b/pkg/filenotify/poller_test.go index 49e6e6486c..228cf58a7d 100644 --- a/pkg/filenotify/poller_test.go +++ b/pkg/filenotify/poller_test.go @@ -89,24 +89,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)