Skip to content

Conversation

ravenblackx
Copy link

@ravenblackx ravenblackx commented Jun 2, 2022

This new option allows the client to avoid the following race condition:

  1. open file "example.txt"
  2. StartTail("example.txt", Location: &SeekInfo(0, io.SeekEnd))
  3. append "hello\n" to example.txt

Without SyncOpen, this sequence may or may not see the line "hello" depending on a race between the goroutine that writes it and the goroutine that Tail runs.

With SyncOpen, the StartTail function doesn't return until the requested seek operation has been performed (unless the file doesn't exist, in which case no seek operation is performed, ensuring position 0 will be used when the file is created), so any writes performed after StartTail are guaranteed to be seen by the tail operation.

Addresses issue #49

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

Successfully merging this pull request may close these issues.

1 participant