filenotify: don't close channels to avoid panic
Tibor Vass authored on 2016/02/20 09:56:27... | ... |
@@ -118,8 +118,10 @@ func (w *filePoller) Close() error { |
118 | 118 |
w.remove(name) |
119 | 119 |
delete(w.watches, name) |
120 | 120 |
} |
121 |
- close(w.events) |
|
122 |
- close(w.errors) |
|
121 |
+ // channels will be closed by GC, we don't do it to avoid panic in send |
|
122 |
+ // functions |
|
123 |
+ // close(w.events) |
|
124 |
+ // close(w.errors) |
|
123 | 125 |
return nil |
124 | 126 |
} |
125 | 127 |
|
... | ... |
@@ -89,24 +89,6 @@ func TestPollerClose(t *testing.T) { |
89 | 89 |
t.Fatal(err) |
90 | 90 |
} |
91 | 91 |
|
92 |
- select { |
|
93 |
- case _, open := <-w.Events(): |
|
94 |
- if open { |
|
95 |
- t.Fatal("event chan should be closed") |
|
96 |
- } |
|
97 |
- default: |
|
98 |
- t.Fatal("event chan should be closed") |
|
99 |
- } |
|
100 |
- |
|
101 |
- select { |
|
102 |
- case _, open := <-w.Errors(): |
|
103 |
- if open { |
|
104 |
- t.Fatal("errors chan should be closed") |
|
105 |
- } |
|
106 |
- default: |
|
107 |
- t.Fatal("errors chan should be closed") |
|
108 |
- } |
|
109 |
- |
|
110 | 92 |
f, err := ioutil.TempFile("", "asdf") |
111 | 93 |
if err != nil { |
112 | 94 |
t.Fatal(err) |