[Netpass-devel] NetPass/bin resetport.pl,1.17,1.18
Brought to you by:
jeffmurphy
From: jeff m. <jef...@us...> - 2005-10-12 20:38:53
|
Update of /cvsroot/netpass/NetPass/bin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2595 Modified Files: resetport.pl Log Message: bug fix. bug caused most jobs to get assigned to same thread, possibly resulting in long delays. Index: resetport.pl =================================================================== RCS file: /cvsroot/netpass/NetPass/bin/resetport.pl,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- resetport.pl 19 Sep 2005 15:26:56 -0000 1.17 +++ resetport.pl 12 Oct 2005 20:38:45 -0000 1.18 @@ -141,7 +141,7 @@ my $np = new NetPass(-cstr => exists $opts{'c'} ? $opts{'c'} : undef, -dbuser => $dbuser, -dbpass => $dbpass, - -debug => exists $opts{'D'} ? 1 : 0, + -debug => 0 , #exists $opts{'D'} ? 1 : 0, # too verbose -quiet => exists $opts{'q'} ? 1 : 0); die "failed to connect to NetPass: $np" unless (ref($np) eq "NetPass"); @@ -175,7 +175,7 @@ my $threads = {}; my $me = threads->self; -my $ps = exists $opts{'t'} ? $opts{'t'} : 50; +my $ps = exists $opts{'t'} ? $opts{'t'} : 20; my $threadPool = {}; my $swThrAffin = {}; @@ -293,17 +293,19 @@ my %qLens; my $firstSeen; - foreach my $tid (keys %$tp) { + foreach my $tid (sort keys %$tp) { lock($tp->{$tid}->{thrq}); $qLens{$tid} = $tp->{$tid}->{'thrq'}->{'workLoad'}; + _log("DEBUG", "$tid workLoad=".$qLens{$tid}."\n"); $firstSeen = $tid unless $firstSeen; } my $assignToMe = ''; my $min = ''; - foreach my $tid (keys %qLens) { - if ( ($min eq '') || ($qLens{$tid} < $min ) ) { + foreach my $tid (sort keys %qLens) { + $min = $qLens{$tid}+1 if ($min eq ''); + if ( $qLens{$tid} < $min ) { $assignToMe = $tid; $min = $qLens{$tid}; } @@ -609,10 +611,10 @@ _log("DEBUG", "$switch/$port checking if resetport is enabled...\n") if exists $opts{'D'}; if (resetPortEnabled($np, $switch, $port) == 0) { - _log("DEBUG", "$switch/$port reset port is disabled for $switch $port. skipping.\n"); + _log("DEBUG", "$switch/$port resetport is disabled for $switch $port. skipping.\n"); next; } - _log("DEBUG", "$switch/$port yes, reserport is enabled and ttype=$ttype\n") if exists $opts{'D'}; + _log("DEBUG", "$switch/$port yes, resetport is enabled and ttype=$ttype\n") if exists $opts{'D'}; if ($ttype == 2) { # LINKDOWN _log("INFO", "$switch/$port LINKDOWN\n"); |