1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

kcc: Factor out MAX_DWORD

Signed-off-by: Garming Sam <garming@catalyst.net.nz>
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Garming Sam 2015-02-24 11:44:11 +13:00 committed by Andrew Bartlett
parent 6a62db3983
commit 99d4efc917
2 changed files with 9 additions and 7 deletions

View File

@ -2315,8 +2315,10 @@ class InternalEdge(object):
################################################## ##################################################
# Global Functions # Global Functions and Variables
################################################## ##################################################
MAX_DWORD = 2 ** 32 - 1
def sort_dsa_by_guid(dsa1, dsa2): def sort_dsa_by_guid(dsa1, dsa2):
return cmp(dsa1.dsa_guid, dsa2.dsa_guid) return cmp(dsa1.dsa_guid, dsa2.dsa_guid)
@ -2358,7 +2360,7 @@ def combine_repl_info(info_a, info_b, info_c):
# Truncate to MAX_DWORD # Truncate to MAX_DWORD
info_c.cost = info_a.cost + info_b.cost info_c.cost = info_a.cost + info_b.cost
if info_c.cost > 2 ** 32 - 1: if info_c.cost > MAX_DWORD:
info_c.cost = 2 ** 32 -1 info_c.cost = MAX_DWORD
return True return True

View File

@ -1697,7 +1697,7 @@ class KCC(object):
v = edge.vertices[0] v = edge.vertices[0]
w = edge.vertices[1] w = edge.vertices[1]
if v.site is vid or w.site is vid: if v.site is vid or w.site is vid:
if (v.is_black() or w.is_black()) and not v.dist_to_red == 2 ** 32 - 1: if (v.is_black() or w.is_black()) and not v.dist_to_red == MAX_DWORD:
edge.directed = True edge.directed = True
if w.dist_to_red < v.dist_to_red: if w.dist_to_red < v.dist_to_red:
@ -2653,7 +2653,7 @@ def create_edge_set(graph, transport, site_link_bridge):
def setup_vertices(graph): def setup_vertices(graph):
for v in graph.vertices: for v in graph.vertices:
if v.is_white(): if v.is_white():
v.repl_info.cost = 2 ** 32 - 1 v.repl_info.cost = MAX_DWORD
v.root = None v.root = None
v.component_id = None v.component_id = None
else: else:
@ -2686,7 +2686,7 @@ def setup_dijkstra(graph, edge_type, include_black, queue):
if ((vertex.is_black() and not include_black) if ((vertex.is_black() and not include_black)
or edge_type not in vertex.accept_black or edge_type not in vertex.accept_black
or edge_type not in vertex.accept_red_red): or edge_type not in vertex.accept_red_red):
vertex.repl_info.cost = 2 ** 32 - 1 vertex.repl_info.cost = MAX_DWORD
vertex.root = None # NULL GUID vertex.root = None # NULL GUID
vertex.demoted = True # Demoted appears not to be used vertex.demoted = True # Demoted appears not to be used
else: else:
@ -2722,7 +2722,7 @@ def check_demote_vertex(vertex, edge_type):
# Accepts neither red-red nor black edges, demote # Accepts neither red-red nor black edges, demote
if edge_type not in vertex.accept_black and edge_type not in vertex.accept_red_red: if edge_type not in vertex.accept_black and edge_type not in vertex.accept_red_red:
vertex.repl_info.cost = 2 ** 32 - 1 vertex.repl_info.cost = MAX_DWORD
vertex.root = None vertex.root = None
vertex.demoted = True # Demoted appears not to be used vertex.demoted = True # Demoted appears not to be used