Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tail will stop when deal with rotate log #189

Open
lwtju opened this issue Sep 8, 2022 · 1 comment
Open

tail will stop when deal with rotate log #189

lwtju opened this issue Sep 8, 2022 · 1 comment

Comments

@lwtju
Copy link

lwtju commented Sep 8, 2022

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants