colse file just one time

This commit is contained in:
miraclesu 2015-12-09 16:38:19 +08:00
parent 6aef373ea6
commit 2bc904e34f
1 changed files with 6 additions and 3 deletions

View File

@ -153,15 +153,18 @@ func (tail *Tail) Stop() error {
func (tail *Tail) close() {
close(tail.Lines)
tail.colseFile()
}
func (tail *Tail) colseFile() {
if tail.file != nil {
tail.file.Close()
tail.file = nil
}
}
func (tail *Tail) reopen() error {
if tail.file != nil {
tail.file.Close()
}
tail.colseFile()
for {
var err error
tail.file, err = OpenFile(tail.Filename)