From 00b7502e668bb0cf798f030fe3ec4deb82e6acf2 Mon Sep 17 00:00:00 2001
From: Robert Ricci <ricci@cs.utah.edu>
Date: Mon, 18 Oct 2004 20:56:41 +0000
Subject: [PATCH] Fix a really old bug - a long time ago, Mac made a change to
 this script to avoid vis-ing parents of subnodes (ie. to avoid vis-ing the PC
 hosting an IXP.) However, this was preventing us from vis-ing fixed nodes at
 all.

---
 vis/prerender.in | 31 ++++++++++++++++++-------------
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/vis/prerender.in b/vis/prerender.in
index d471fe9660..750a32c43a 100644
--- a/vis/prerender.in
+++ b/vis/prerender.in
@@ -149,27 +149,31 @@ my $fixednodes = ();
 # all virt_nodes are visualizer nodes of type "node"
 while (my ($vname,$fixed) = $result->fetchrow) {
     dprint "node $vname $fixed\t";
-    if (!defined($fixednodes{$vname})) {
-	# This node is not a parent node, so we can add it
-	$nodes{$vname}{"type"} = "node";
-	dprint "added nodes($vname)\t";
-    } else {
-	dprint "$vname is a fixed host!\t";
-    }
+    $nodes{$vname}{"type"} = "node";
+    dprint "added nodes($vname)\t";
     if (defined($fixed) && $fixed ne "") {
 	# $vname is a subnode of $fixed, so we don't want
 	# to viz any vnames named $fixed
 	dprint "adding fixed($fixed)\t";
-	$fixednodes{$fixed} = $vname;
-	if (defined($nodes{$fixed})) {
-	    # Remove the node if it is already there
-	    delete $nodes{$fixed};
-	    dprint "rm nodes($fixed)\t";
-	}
+	$fixednodes{$vname} = $fixed;
     }
     dprint "\n";
 }
 
+# make another pass, removing parent nodes of subnodes
+foreach my $fixednode (keys %fixednodes) {
+    my $fixedto = $fixednodes{$fixednode};
+    if ($fixedto eq $fixednode) {
+	# ignore nodes that are fixed in place to themselves
+	next;
+    }
+     # if $fixednode is $fixedto some other node in the topology, don't
+     # vis the partent
+     if (exists $nodes{$fixedto}) {
+	 delete $nodes{$fixedto};
+     }
+}
+
 # read lans
 
 $result = DBQueryWarn("SELECT vname, member FROM virt_lans " .
@@ -455,6 +459,7 @@ for ($attempt = 0; $attempt < 16; $attempt++) {
     # the render finishes, which is quite possible on giant experiments.
     #
     if (!defined $bestOverlaps || $overlaps < $bestOverlaps) {
+	dprint "Saving config\n";
 	$bestOverlaps = $overlaps;
 
         # We have to lock the table so as not to cause grief to someone
-- 
GitLab