marsadm: fix fake_versionlink()

Always fake two versionslinks instead of one.
This commit is contained in:
Thomas Schoebel-Theuer 2014-03-05 16:10:35 +01:00 committed by Thomas Schoebel-Theuer
parent e5a558aefe
commit 59cce71e2d

View File

@ -843,7 +843,8 @@ sub _get_ip {
sub _fake_versionlink { sub _fake_versionlink {
my ($basedir, $log_nr, $primary) = @_; my ($basedir, $log_nr, $primary) = @_;
for (my $rounds = 2; $rounds > 0; $rounds--) { my $make_count = 0;
for (my $rounds = 2; $rounds > 0 && $log_nr > 0; $rounds--) {
my $new_version = sprintf("$basedir/version-%09d-$host", $log_nr); my $new_version = sprintf("$basedir/version-%09d-$host", $log_nr);
my $pri_version = sprintf("$basedir/version-%09d-$primary", $log_nr); my $pri_version = sprintf("$basedir/version-%09d-$primary", $log_nr);
if ($primary eq $host) { if ($primary eq $host) {
@ -851,14 +852,15 @@ sub _fake_versionlink {
} }
my $pri_link = get_link($pri_version, 1); my $pri_link = get_link($pri_version, 1);
if (!$pri_link) { if (!$pri_link) {
lwarn "cannot read symlink '$pri_version' -- cannot create faked versionlink '$pri_version'\n";
$log_nr++; $log_nr++;
next; next;
} }
lprint "creating new version symlink '$new_version' -> '$pri_link'\n"; lprint "creating new version symlink '$new_version' -> '$pri_link'\n";
set_link($pri_link, $new_version); set_link($pri_link, $new_version);
last; $make_count++;
$log_nr--;
} }
lwarn "cannot create faked versionlink\n" if !$make_count;
} }
sub _set_replaylink { sub _set_replaylink {