LGTM, thanks
On Thu, Feb 20, 2014 at 5:02 PM, Klaus Aehlig <[email protected]> wrote: > As it is an operation the locking daemon is supposed to provide, > add a function restricting the locks of a user to a given list > and release all other locks. > > Signed-off-by: Klaus Aehlig <[email protected]> > --- > src/Ganeti/Locking/Allocation.hs | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/src/Ganeti/Locking/Allocation.hs > b/src/Ganeti/Locking/Allocation.hs > index 3b03f1d..215f68d 100644 > --- a/src/Ganeti/Locking/Allocation.hs > +++ b/src/Ganeti/Locking/Allocation.hs > @@ -34,6 +34,7 @@ module Ganeti.Locking.Allocation > , requestRelease > , updateLocks > , freeLocks > + , intersectLocks > ) where > > import Control.Arrow (second, (***)) > @@ -285,3 +286,12 @@ 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 > + > +-- | Restrict the locks of a user to a given set. > +intersectLocks :: (Lock a, Ord b) => b -> [a] > + -> LockAllocation a b -> LockAllocation a b > +intersectLocks owner locks state = > + let lockset = S.fromList locks > + toFree = filter (not . flip S.member lockset) > + . M.keys $ listLocks owner state > + in fst $ updateLocks owner (map requestRelease toFree) state > -- > 1.9.0.rc1.175.g0b1dcb5 > >
