LockSet: make acquire() able to get the whole set
authorGuido Trotter <ultrotter@google.com>
Tue, 4 Mar 2008 13:18:22 +0000 (13:18 +0000)
committerGuido Trotter <ultrotter@google.com>
Tue, 4 Mar 2008 13:18:22 +0000 (13:18 +0000)
commit3b7ed473b3e4c1449811d26f0458c5cebe3733a1
treedc262f5b03cf2204e4267f2330c3c66d6e7e36bc
parent806e20fd8cc68c07301005c3e8237c5cacec5ba1
LockSet: make acquire() able to get the whole set

This new functionality makes it possible to acquire a whole set, by passing
"None" to the acquire() function as the list of elements. This will avoid new
additions to the set, and then acquire all the current elements. The list of
all elements acquired will be returned at the end.

Deletions can still happen during the acquire process and we'll deal with it by
just skipping the deleted elements: it's effectively as if they were deleted
before we called the function. After we've finished though we hold all the
elements, so no more deletes can be performed before we release them.

Any call to release() will then first of all release the "set-level" lock if
we're holding it, and then all or some of the locks we have.

Some new tests checks that this feature works as intended.

Reviewed-by: imsnah
lib/locking.py
test/ganeti.locking_unittest.py