Francesco Romani has uploaded a new change for review. Change subject: sampling: fix semaphore misusing ......................................................................
sampling: fix semaphore misusing We should release the internal _sampling semaphore only if we acquired it succesfully. Otherwise, if a previous call was stuck, we violate the contract of the semaphore. Change-Id: I9b67cc4efe70b5d2ec8838ace6dfb16648528c46 Backport-To: 3.6 Signed-off-by: Francesco Romani <from...@redhat.com> --- M vdsm/virt/sampling.py 1 file changed, 4 insertions(+), 3 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/32/48332/1 diff --git a/vdsm/virt/sampling.py b/vdsm/virt/sampling.py index 1026eaf..3eaf376 100644 --- a/vdsm/virt/sampling.py +++ b/vdsm/virt/sampling.py @@ -492,10 +492,10 @@ def __call__(self): timestamp = self._stats_cache.clock() + acquired = self._sampling.acquire(blocking=False) # we are deep in the hot path. bool(ExpiringCache) # *is* costly so we should avoid it if we can. - fast_path = ( - self._sampling.acquire(blocking=False) and not self._skip_doms) + fast_path = acquired and not self._skip_doms try: if fast_path: # This is expected to be the common case. @@ -516,7 +516,8 @@ else: self._stats_cache.put(_translate(bulk_stats), timestamp) finally: - self._sampling.release() + if acquired: + self._sampling.release() def _get_responsive_doms(self): vms = self._get_vms() -- To view, visit https://gerrit.ovirt.org/48332 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9b67cc4efe70b5d2ec8838ace6dfb16648528c46 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Francesco Romani <from...@redhat.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches