Nir Soffer has uploaded a new change for review. Change subject: domainMonitor: Fix unsafe iteration ......................................................................
domainMonitor: Fix unsafe iteration Using dict.iteritems() is safe only if nobody else can modify the dictionary while iterating. However in DomainMonitor, others threads can add or remove items during the iteration, so we must use dict.items(), which copies the keys and values atomically. dict.iteritems() is useful when we have huge dict and we don't want to create a huge list of items, but in case of the domain monitor, where we have less then 100 monitors, there is not need for fancy iteration. While modifying this line, I also improve the names to make the code more clear, this can be separated to another patch but I don't think it is needed in this case. Change-Id: I5313d25c7148e4a0362d19fe31d2e78f94c26e39 Signed-off-by: Nir Soffer <[email protected]> --- M vdsm/storage/domainMonitor.py 1 file changed, 2 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/07/29007/1 diff --git a/vdsm/storage/domainMonitor.py b/vdsm/storage/domainMonitor.py index 8a50b4f..76afafa 100644 --- a/vdsm/storage/domainMonitor.py +++ b/vdsm/storage/domainMonitor.py @@ -87,7 +87,8 @@ @property def poolMonitoredDomains(self): - return [k for k, v in self._domains.iteritems() if v.poolDomain] + return [sdUUID for sdUUID, monitor in self._domains.items() + if monitor.poolDomain] def startMonitoring(self, sdUUID, hostId, poolDomain=True): domainThread = self._domains.get(sdUUID) -- To view, visit http://gerrit.ovirt.org/29007 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5313d25c7148e4a0362d19fe31d2e78f94c26e39 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
