From ed45d465c5d7451afc3accce439ca335faae4af7 Mon Sep 17 00:00:00 2001 From: yangsbj Date: Fri, 10 Aug 2018 05:12:20 -0400 Subject: [PATCH] MacMap: skip obtaining macmap table from switches without any port connect to switchs and pdus while discovering switch --- perl-xCAT/xCAT/MacMap.pm | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/perl-xCAT/xCAT/MacMap.pm b/perl-xCAT/xCAT/MacMap.pm index 1c8668411..a0d42062a 100644 --- a/perl-xCAT/xCAT/MacMap.pm +++ b/perl-xCAT/xCAT/MacMap.pm @@ -529,17 +529,14 @@ sub refresh_table { xCAT::MsgUtils->message("S", "xCAT Table error:" . $entry->{node} . "Has missing or invalid switch.switch and/or switch.port fields"); } } + my $children = 0; my $inputs = new IO::Select; $SIG{CHLD} = sub { while (waitpid(-1, WNOHANG) > 0) { $children-- } }; - foreach my $entry (@entries) { - if ($checked_pairs{ $entry->{switch} }) { - next; - } + foreach my $entry (keys $self->{switches}) { while ($children > 64) { $self->handle_output($inputs); } - $checked_pairs{ $entry->{switch} } = 1; pipe my $child, my $parent; $child->autoflush(1); $parent->autoflush(1); @@ -550,7 +547,7 @@ sub refresh_table { $children--; close($child); close($parent); - xCAT::MsgUtils->message("S", "refresh_table: failed to fork refresh_switch process for $entry->{switch},skip..."); + xCAT::MsgUtils->message("S", "refresh_table: failed to fork refresh_switch process for $entry,skip..."); next; } @@ -558,10 +555,10 @@ sub refresh_table { $SIG{CHLD} = 'DEFAULT'; close($child); my $runstart = time; - $self->refresh_switch($parent, $community, $entry->{switch}); + $self->refresh_switch($parent, $community, $entry); my $runstop = time; my $diffduration = $runstop - $runstart; - xCAT::MsgUtils->trace(0, ($diffduration > 10) ? "w" : "d", "refresh_switch $entry->{switch} ElapsedTime:$diffduration sec"); + xCAT::MsgUtils->trace(0, ($diffduration > 10) ? "w" : "d", "refresh_switch $entry ElapsedTime:$diffduration sec"); exit(0); } close($parent);