« Previous | Next » 

Revision 6683bba2

Parent 5685c1a5
Child 082c5adb

Added by Guido Trotter over 15 years ago

Fix issue when acquiring empty lock sets

By design if an empty list of locks is acquired from a set, no locks are
acquired, and thus release() cannot be called on the set. On the other
hand if None is passed instead of the list, the whole set is acquired,
and must later be released. When acquiring whole empty sets, a release
must happen too, because the set-lock is acquired.

Since we used to overwrite the required locks (needed_locks) with the
acquired ones, we weren't able to distinguish the two cases (empty list
of locks required, and all locks required, but an empty list returned
because the set is empty). Valid solutions include:
(1) forbidding the acquire of empty lists of locks
(2) skipping the acquire/release on empty lists of locks
(3) separating the to-acquire and the acquired list

This patch implements the third approach, and thus LUs will find
acquired locks in the acquired_locks dict, rather than in needed_locks.
The LUs which used this feature before have been updated. This makes it
easier because it doesn't force LUs to do more checks on corner cases,
which are easily forgettable (1) and allows more flexibility if we want
LUs to release (part-of) the locks (which is still a possibly scary
operation, but anyway). This easily combines with (2) should we choose
to implement it.

Reviewed-by: imsnah


  • added
  • modified
  • copied
  • renamed
  • deleted

View differences