Commit 6cfc67c5 authored by Klaus Aehlig's avatar Klaus Aehlig
Browse files

Always eventually free release the BGL



Move the release statement for the BGL to the finally block
enclosing the statement that acquired it. In this way, we are
sure to always eventually release the BGL. Also replace the
freeing request by a FreeLocksLevel request, which also cancels
all pending requests that still might exist.
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarPetr Pudlak <pudlak@google.com>
parent c14e8de5
......@@ -633,26 +633,21 @@ class Processor(object):
raise errors.ProgrammerError("Opcode '%s' requires BGL, but locks are"
" disabled" % op.OP_ID)
lu = lu_class(self, op, self.context, self.cfg, self.rpc,
self._wconfdcontext, self.wconfd)
lu.wconfdlocks = self.wconfd.Client().ListLocks(self._wconfdcontext)
lu.ExpandNames()
assert lu.needed_locks is not None, "needed_locks not set by LU"
try:
lu = lu_class(self, op, self.context, self.cfg, self.rpc,
self._wconfdcontext, self.wconfd)
lu.wconfdlocks = self.wconfd.Client().ListLocks(self._wconfdcontext)
lu.ExpandNames()
assert lu.needed_locks is not None, "needed_locks not set by LU"
try:
result = self._LockAndExecLU(lu, locking.LEVEL_CLUSTER + 1,
calc_timeout)
finally:
if self._ec_id:
self.cfg.DropECReservations(self._ec_id)
result = self._LockAndExecLU(lu, locking.LEVEL_CLUSTER + 1,
calc_timeout)
finally:
# Release BGL if owned
bglname = "%s/%s" % (locking.LEVEL_NAMES[locking.LEVEL_CLUSTER],
locking.BGL)
self.wconfd.Client().TryUpdateLocks(self._wconfdcontext,
[[bglname, "release"]])
if self._ec_id:
self.cfg.DropECReservations(self._ec_id)
finally:
self.wconfd.Client().FreeLocksLevel(
self._wconfdcontext, locking.LEVEL_NAMES[locking.LEVEL_CLUSTER])
self._cbs = None
self._CheckLUResult(op, result)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment