Re: [PATCH 05/11] cache-tree: simplify locking logic

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Oct 01, 2017 at 04:56:06PM +0200, Martin Ågren wrote:

> After we have taken the lock using `LOCK_DIE_ON_ERROR`, we know that
> `newfd` is non-negative. So when we check for exactly that property
> before calling `write_locked_index()`, the outcome is guaranteed.
> 
> If we write and commit successfully, we set `newfd = -1`, so that we can
> later avoid calling `rollback_lock_file` on an already-committed lock.
> But we might just as well unconditionally call `rollback_lock_file()` --
> it will be a no-op if we have already committed.
> 
> All in all, we use `newfd` as a bool and the only benefit we get from it
> is that we can avoid calling a no-op. Remove `newfd` so that we have one
> variable less to reason about.

Nice, this looks much simpler and the reasoning above is all sound.

I think cmd_checkout_index() has the exact same thing going on.

-Peff



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux