fix reader nil pointer

This commit is contained in:
miraclesu 2016-01-25 14:19:23 +08:00 committed by Nino Khodabandeh
parent adca23eea0
commit b2940955ab
1 changed files with 10 additions and 4 deletions

14
tail.go
View File

@ -143,11 +143,17 @@ func (tail *Tail) Tell() (offset int64, err error) {
return return
} }
offset, err = tail.file.Seek(0, os.SEEK_CUR) offset, err = tail.file.Seek(0, os.SEEK_CUR)
if err == nil { if err != nil {
tail.lk.Lock() return
offset -= int64(tail.reader.Buffered())
tail.lk.Unlock()
} }
tail.lk.Lock()
defer tail.lk.Unlock()
if tail.reader == nil {
return
}
offset -= int64(tail.reader.Buffered())
return return
} }