add file poller panic fix from 1.10.2
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
parent
d932514e7e
commit
c8da8b3693
2 changed files with 1 additions and 20 deletions
|
@ -118,8 +118,6 @@ func (w *filePoller) Close() error {
|
||||||
w.remove(name)
|
w.remove(name)
|
||||||
delete(w.watches, name)
|
delete(w.watches, name)
|
||||||
}
|
}
|
||||||
close(w.events)
|
|
||||||
close(w.errors)
|
|
||||||
return nil
|
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
|
// watch is responsible for polling the specified file for changes
|
||||||
// upon finding changes to a file or errors, sendEvent/sendErr is called
|
// 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{}) {
|
func (w *filePoller) watch(f *os.File, lastFi os.FileInfo, chClose chan struct{}) {
|
||||||
|
defer f.Close()
|
||||||
for {
|
for {
|
||||||
time.Sleep(watchWaitTime)
|
time.Sleep(watchWaitTime)
|
||||||
select {
|
select {
|
||||||
|
|
|
@ -93,24 +93,6 @@ func TestPollerClose(t *testing.T) {
|
||||||
t.Fatal(err)
|
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")
|
f, err := ioutil.TempFile("", "asdf")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
|
Loading…
Reference in a new issue