Permalink
Browse files

Fix bug where multiple parser instances may be updating the file at t…

…he same time.
  • Loading branch information...
1 parent 3f4926f commit a09010649dd64c21e9815204e48a3b52ff5b93d2 @jamesotron jamesotron committed Mar 12, 2012
Showing with 7 additions and 1 deletion.
  1. +7 −1 lib/rltk/parser.rb
View
@@ -645,7 +645,13 @@ def finalize(opts = {})
self.clean
# Store the parser's final data structures if requested.
- Marshal.dump([@lh_sides, @states, @symbols], self.get_io(opts[:use])) if opts[:use]
+ if opts[:use]
+ file = self.get_io(opts[:use])
+ file.flock(File::LOCK_EX)
+ Marshal.dump([@lh_sides, @states, @symbols], file)
+ file.flock(File::LOCK_UN)
+ file.close
+ end
end
# Converts an object into an IO object as appropriate.

0 comments on commit a090106

Please sign in to comment.