hpcloud / tail

Go package for reading from continously updated files (tail -f)
MIT License
2.7k stars 502 forks source link

tail will stop when deal with rotate log #189

Open lwtju opened 1 year ago

lwtju commented 1 year ago

it will stop when tail the log which is deleted periodically and a new one created. I think it cased by the code follow:

func (fc *FileChanges) NotifyDeleted() { sendOnlyIfEmpty(fc.Deleted) }

// sendOnlyIfEmpty sends on a bool channel only if the channel has no // backlog to be read by other goroutines. This concurrency pattern // can be used to notify other goroutines if and only if they are // looking for it (i.e., subsequent notifications can be compressed // into one). func sendOnlyIfEmpty(ch chan bool) { select { case ch <- true: default: } }

sendOnlyIfEmpty will not send true until the recevier of fc.Deleted is ready. And the receiver comes to be ready only when io.EOF appears. That means when EOF comes, the event of deleted has passed away. waitForChanges() can not do anything but wait.

image

so, notifyDeleted should wait (drop sendOnlyIfEmpty). it is different with modified event. By the way, the name of sendOnlyIfEmpty makes confused.

qq911712051 commented 1 year ago

it has bugs in rolling-log, and lost events.