Change in vdsm[master]: BZ#771329 Use a copy of the domainsToUpgrade

danken at redhat.com danken at redhat.com
Sat Jan 14 12:49:47 UTC 2012


Dan Kenigsberg has submitted this change and it was merged.

Change subject: BZ#771329 Use a copy of the domainsToUpgrade
......................................................................


BZ#771329 Use a copy of the domainsToUpgrade

The original code just uses another ref that is changed while iterated
which has unexpected results. This was not apparent as the remove might
happened after the iteration because it might run in another thread.

To illustrate:

In [1]: a = [1,2,3,4,5,6,7,8,9,10]

In [2]: for i in a:
...:     a.remove(i)
...:

In [3]: a
Out[3]: [2, 4, 6, 8, 10]

In [4]: for i in a:
...:     a.remove(i)
...:

In [5]: a
Out[5]: [4, 8]

In [6]: for i in a[:]:
...:     a.remove(i)
...:

In [7]: a
Out[7]: []

Fun!

Change-Id: I3de0646af2fe9a9fcde708837cfcd83d10385026
---
M vdsm/storage/sp.py
1 file changed, 1 insertion(+), 1 deletion(-)

Approvals:
  Dan Kenigsberg: Verified; Looks good to me, approved


--
To view, visit http://gerrit.ovirt.org/900
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I3de0646af2fe9a9fcde708837cfcd83d10385026
Gerrit-PatchSet: 2
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Saggi Mizrahi <smizrahi at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Saggi Mizrahi <smizrahi at redhat.com>


More information about the vdsm-patches mailing list