LGTM, thanks.

On Tue, Feb 18, 2014 at 3:28 PM, Klaus Aehlig <[email protected]> wrote:

> Most requests for lock updates are consistent and mention
> every lock only once. So verify this property efficiently
> by comparing lengths. Only if the length do not coincide
> go through the actual (quadratic) comparison to find a
> counterexample.
>
> Signed-off-by: Klaus Aehlig <[email protected]>
> ---
>  src/Ganeti/Locking/Allocation.hs | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/src/Ganeti/Locking/Allocation.hs
> b/src/Ganeti/Locking/Allocation.hs
> index 4df8396..9c28741 100644
> --- a/src/Ganeti/Locking/Allocation.hs
> +++ b/src/Ganeti/Locking/Allocation.hs
> @@ -206,8 +206,9 @@ updateLocks :: (Lock a, Ord b)
>              -> [LockRequest a]
>              -> LockAllocation a b -> (LockAllocation a b, Result (S.Set
> b))
>  updateLocks owner reqs state = genericResult ((,) state . Bad) (second
> Ok) $ do
> -  runListHead (return ())
> -              (fail . (++) "Inconsitent requests for lock " . show) $ do
> +  unless ((==) (length reqs) . S.size . S.fromList $ map lockAffected
> reqs)
> +    . runListHead (return ())
> +                  (fail . (++) "Inconsitent requests for lock " . show) $
> do
>        r <- reqs
>        r' <- reqs
>        guard $ r /= r'
> --
> 1.9.0.rc1.175.g0b1dcb5
>
>

Reply via email to