+ my $s;
+ if (defined ($s = $by_host{$mach})) {
+ delete $s->{'Gone'};
+ } else {
+ my ($best, $besti);
+ for my $i (0..$nrows-1) {
+ my $r = $by_row[$i];
+ if (!defined $r) {
+ $besti = $i;
+ $best = undef;
+ last;
+ } elsif ($r->{'Gone'} && (!$best || $best->{'Gone'} > $r->{'Gone'})) {
+ $besti = $i;
+ $best = $r;
+ }
+ }
+ if ($best) {
+ delete $by_host{$best->{'Host'}};
+ }
+ $s->{'Host'} = $mach;
+ $s->{'Row'} = $besti;
+ $by_host{$mach} = $s;
+ $by_row[$besti] = $s;