Skip to content
Permalink
Browse files

flock the file while we're modifying it

Because we're seeking and appending, things can get confused if a second
process is attempting to update the same file at the same time. This
could mean we end up waiting for another process to finish what it's
doing, but that's fine: it's doing the very thing we'd otherwise be
spending our cycles on, so the wait isn't wasted.
  • Loading branch information...
matthewd committed Oct 6, 2019
1 parent d76d69c commit 316429e2bc98513bce07d36cf94b8436d50eb703
Showing with 2 additions and 0 deletions.
  1. +2 −0 lib/gel/tail_file.rb
@@ -40,6 +40,8 @@ def update(force_reset: false)
uri = self.uri

File.open(@filename, "a+b") do |f|
f.flock(File::LOCK_EX)

f.seek(0, IO::SEEK_END)

MAXIMUM_CHAIN.times do

0 comments on commit 316429e

Please sign in to comment.
You can’t perform that action at this time.