Michael Barton b908a65649 lock_file race fixes
I attempted to use this function and found a few problems.

We shouldn’t unlink the file after closing it, because someone else could lock
it in between.  Switch to unlink before close.

If someone else locked the file between our open and flock, they are likely to
unlink it out from underneath us.  Then we have a lock on a file that no longer
exists.  So stat the filename after locking to make sure the inode hasn't
changed or gone away.

We probably shouldn’t unlink the file if we time out waiting for a lock.  So
move that to before the finally block.

Change-Id: Id1858c97805d3ab81c584eaee8ce0d43d34a8089
2014-07-21 08:49:27 +00:00
..
2014-07-02 10:49:38 -07:00
2014-07-21 08:49:27 +00:00
2014-04-30 12:17:25 -06:00