Navigation Menu

Skip to content

Commit

Permalink
Perlop reminder, rewriting it
Browse files Browse the repository at this point in the history
  • Loading branch information
rgeissert committed Jan 23, 2012
1 parent 7c28e50 commit eeaf561
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions redir.pl
Expand Up @@ -65,7 +65,7 @@
sub print_xtra($$);
sub find_arch($@);
sub clean_url($);
sub consider_mirror($$);
sub consider_mirror($);


$mirror_type = $q->param('mirror') || 'archive';
Expand Down Expand Up @@ -136,13 +136,13 @@

# match by AS
foreach my $match (@{$rdb->{'AS'}{$as}}) {
$match_type ||= consider_mirror ($match, 'AS');
$match_type = 'AS' if (consider_mirror ($match));
}

# match by country
if (!$match_type) {
foreach my $match (keys %{$rdb->{'country'}{$geo_rec->country_code}}) {
$match_type ||= consider_mirror ($match, 'country');
$match_type = 'country' if (consider_mirror ($match));
}
}

Expand All @@ -159,7 +159,7 @@
} else {
$mtype = 'nearby-continent';
}
$match_type ||= consider_mirror ($match, $mtype);
$match_type = $mtype if (consider_mirror ($match));
}
}
}
Expand Down Expand Up @@ -288,15 +288,15 @@ ($)
return $url;
}

sub consider_mirror($$) {
my ($id, $match_type) = @_;
sub consider_mirror($) {
my ($id) = @_;

my $mirror = $db->{'all'}{$id};

return '' unless fullfils_request($db->{$mirror_type}, $id);
return 0 unless fullfils_request($db->{$mirror_type}, $id);

my $host = $mirror->{'site'}.$mirror->{$mirror_type.'-http'};
$hosts{$host} = calculate_distance($mirror->{'lon'}, $mirror->{'lat'},
$geo_rec->longitude, $geo_rec->latitude);
return $match_type;
return 1;
}

0 comments on commit eeaf561

Please sign in to comment.