Skip to content

Commit b4143c2

Browse files
phemmerdanielnelson
authored andcommitted
add lock around tail.reader to prevent race (#1)
1 parent 517cb79 commit b4143c2

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

tail.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,12 +391,14 @@ func (tail *Tail) waitForChanges() error {
391391
}
392392

393393
func (tail *Tail) openReader() {
394+
tail.lk.Lock()
394395
if tail.MaxLineSize > 0 {
395396
// add 2 to account for newline characters
396397
tail.reader = bufio.NewReaderSize(tail.file, tail.MaxLineSize+2)
397398
} else {
398399
tail.reader = bufio.NewReader(tail.file)
399400
}
401+
tail.lk.Unlock()
400402
}
401403

402404
func (tail *Tail) seekEnd() error {

0 commit comments

Comments
 (0)