LGTM, thanks.

On Wed, Feb 19, 2014 at 12:50 PM, Klaus Aehlig <[email protected]> wrote:

> While freeing all locks of a single owner can easily be defined
> out of listLocks and updateLocks, it is worth having this function
> in its own right. For example, it will be needed when the death of
> a job is detected.
>
> Signed-off-by: Klaus Aehlig <[email protected]>
> ---
>  src/Ganeti/Locking/Allocation.hs | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/src/Ganeti/Locking/Allocation.hs
> b/src/Ganeti/Locking/Allocation.hs
> index 1034fe5..46db865 100644
> --- a/src/Ganeti/Locking/Allocation.hs
> +++ b/src/Ganeti/Locking/Allocation.hs
> @@ -33,6 +33,7 @@ module Ganeti.Locking.Allocation
>    , requestShared
>    , requestRelease
>    , updateLocks
> +  , freeLocks
>    ) where
>
>  import Control.Arrow (second, (***))
> @@ -197,3 +198,9 @@ updateLocks owner reqs state = genericResult ((,)
> state . Bad) (second Ok) $ do
>    let blocked = S.delete owner . S.unions $ map blockedOn reqs
>    let state' = foldl (updateLock owner) state reqs
>    return (if S.null blocked then state' else state, blocked)
> +
> +-- | Compute the state after an onwer releases all its locks.
> +freeLocks :: (Lock a, Ord b) => LockAllocation a b -> b -> LockAllocation
> a b
> +freeLocks state owner =
> +  fst . flip (updateLocks owner) state . map requestRelease . M.keys
> +    $ listLocks owner state
> --
> 1.9.0.rc1.175.g0b1dcb5
>
>

Reply via email to