remove a redundant goroutine
This commit is contained in:
parent
ec461b87f0
commit
1336a0e4ab
17
watch.go
17
watch.go
|
@ -120,10 +120,10 @@ func (fw *PollingFileWatcher) ChangeEvents(origFi os.FileInfo) chan bool {
|
||||||
ch := make(chan bool)
|
ch := make(chan bool)
|
||||||
stop := make(chan bool)
|
stop := make(chan bool)
|
||||||
var once sync.Once
|
var once sync.Once
|
||||||
every2Seconds := time.Tick(2 * time.Second)
|
|
||||||
var prevModTime time.Time
|
var prevModTime time.Time
|
||||||
|
|
||||||
// XXX: use tomb.Tomb to cleanly managed these goroutines.
|
// XXX: use tomb.Tomb to cleanly manage these goroutines. replace
|
||||||
|
// the panic (below) with tomb's Kill.
|
||||||
|
|
||||||
stopAndClose := func() {
|
stopAndClose := func() {
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -169,19 +169,6 @@ func (fw *PollingFileWatcher) ChangeEvents(origFi os.FileInfo) chan bool {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
go func() {
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case <-every2Seconds:
|
|
||||||
// XXX: not using file descriptor as per contract.
|
|
||||||
if _, err := os.Stat(fw.Filename); os.IsNotExist(err) {
|
|
||||||
once.Do(stopAndClose)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
return ch
|
return ch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue