1
0
mirror of https://github.com/CumulusNetworks/ifupdown2.git synced 2024-05-06 15:54:50 +00:00

make a copy of the indegrees dict in the graph module

Ticket: CM-2731
Reviewed By:
Testing Done: Tested ifupdown sanity

The graph module modifies the indegrees array and so introduce a copy
of the dict before modifying it.
This commit is contained in:
roopa
2014-05-07 23:20:04 -07:00
parent f90dd03886
commit 615234a10d

View File

@ -8,6 +8,7 @@
# #
import logging import logging
import copy
from collections import deque from collections import deque
try: try:
from gvgen import * from gvgen import *
@ -21,10 +22,11 @@ class graph():
self.__class__.__name__) self.__class__.__name__)
@classmethod @classmethod
def topological_sort_graphs_all(cls, dependency_graphs, indegrees): def topological_sort_graphs_all(cls, dependency_graphs, indegrees_arg):
S = [] S = []
Q = deque() Q = deque()
indegrees = copy.deepcopy(indegrees_arg)
for ifname,indegree in indegrees.items(): for ifname,indegree in indegrees.items():
if indegree == 0: if indegree == 0:
Q.append(ifname) Q.append(ifname)