mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 11:01:52 +01:00
Merge kahlann.erinye.com:/home/df/mysql/build/mysql-4.1-build-work
into kahlann.erinye.com:/home/df/mysql/build/mysql-5.0-build-work
This commit is contained in:
commit
728357200c
1 changed files with 40 additions and 3 deletions
|
@ -35,6 +35,13 @@ sub mtr_require_unique_id($$$) {
|
||||||
my $min = shift;
|
my $min = shift;
|
||||||
my $max = shift;
|
my $max = shift;
|
||||||
my $ret = undef;
|
my $ret = undef;
|
||||||
|
my $changed = 0;
|
||||||
|
|
||||||
|
my $can_use_ps = `ps -e | grep '^[ ]*$$ '`;
|
||||||
|
|
||||||
|
if(eval("readlink '$file'") || eval("readlink '$file.sem'")) {
|
||||||
|
die 'lock file is a symbolic link';
|
||||||
|
}
|
||||||
|
|
||||||
chmod 0777, "$file.sem";
|
chmod 0777, "$file.sem";
|
||||||
open SEM, ">", "$file.sem" or die "can't write to $file.sem";
|
open SEM, ">", "$file.sem" or die "can't write to $file.sem";
|
||||||
|
@ -43,6 +50,11 @@ sub mtr_require_unique_id($$$) {
|
||||||
open FILE, ">", $file or die "can't create $file";
|
open FILE, ">", $file or die "can't create $file";
|
||||||
close FILE;
|
close FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(eval("readlink '$file'") || eval("readlink '$file.sem'")) {
|
||||||
|
die 'lock file is a symbolic link';
|
||||||
|
}
|
||||||
|
|
||||||
chmod 0777, $file;
|
chmod 0777, $file;
|
||||||
open FILE, "+<", $file or die "can't open $file";
|
open FILE, "+<", $file or die "can't open $file";
|
||||||
select undef,undef,undef,0.2;
|
select undef,undef,undef,0.2;
|
||||||
|
@ -52,15 +64,30 @@ sub mtr_require_unique_id($$$) {
|
||||||
chomp;
|
chomp;
|
||||||
my ($id, $pid) = split / /;
|
my ($id, $pid) = split / /;
|
||||||
$taken{$id} = $pid;
|
$taken{$id} = $pid;
|
||||||
|
if($can_use_ps) {
|
||||||
|
my $res = `ps -e | grep '^[ ]*$pid '`;
|
||||||
|
if(!$res) {
|
||||||
|
print "Ignoring slot $id used by missing process $pid.\n";
|
||||||
|
delete $taken{$id};
|
||||||
|
++$changed;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
seek FILE, 0, 2;
|
|
||||||
for(my $i=$min; $i<=$max; ++$i) {
|
for(my $i=$min; $i<=$max; ++$i) {
|
||||||
if(! exists $taken{$i}) {
|
if(! exists $taken{$i}) {
|
||||||
print FILE "$i $$\n";
|
|
||||||
$ret = $i;
|
$ret = $i;
|
||||||
|
$taken{$i} = $$;
|
||||||
|
++$changed;
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if($changed) {
|
||||||
|
seek FILE, 0, 0;
|
||||||
|
truncate FILE, 0 or die "can't truncate $file";
|
||||||
|
for my $k (keys %taken) {
|
||||||
|
print FILE $k . ' ' . $taken{$k} . "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
close FILE;
|
close FILE;
|
||||||
flock SEM, LOCK_UN or warn "can't unlock $file.sem";
|
flock SEM, LOCK_UN or warn "can't unlock $file.sem";
|
||||||
close SEM;
|
close SEM;
|
||||||
|
@ -75,8 +102,9 @@ sub mtr_require_unique_id($$$) {
|
||||||
sub mtr_require_unique_id_and_wait($$$) {
|
sub mtr_require_unique_id_and_wait($$$) {
|
||||||
my $ret = mtr_require_unique_id($_[0],$_[1],$_[2]);
|
my $ret = mtr_require_unique_id($_[0],$_[1],$_[2]);
|
||||||
while(! defined $ret) {
|
while(! defined $ret) {
|
||||||
sleep 10;
|
sleep 30;
|
||||||
$ret = mtr_require_unique_id($_[0],$_[1],$_[2]);
|
$ret = mtr_require_unique_id($_[0],$_[1],$_[2]);
|
||||||
|
print "Waiting for unique id to become available...\n" unless $ret;
|
||||||
}
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
@ -88,8 +116,17 @@ sub mtr_release_unique_id($$) {
|
||||||
my $file = shift;
|
my $file = shift;
|
||||||
my $myid = shift;
|
my $myid = shift;
|
||||||
|
|
||||||
|
if(eval("readlink '$file'") || eval("readlink '$file.sem'")) {
|
||||||
|
die 'lock file is a symbolic link';
|
||||||
|
}
|
||||||
|
|
||||||
open SEM, ">", "$file.sem" or die "can't write to $file.sem";
|
open SEM, ">", "$file.sem" or die "can't write to $file.sem";
|
||||||
flock SEM, LOCK_EX or die "can't lock $file.sem";
|
flock SEM, LOCK_EX or die "can't lock $file.sem";
|
||||||
|
|
||||||
|
if(eval("readlink '$file'") || eval("readlink '$file.sem'")) {
|
||||||
|
die 'lock file is a symbolic link';
|
||||||
|
}
|
||||||
|
|
||||||
if(! -e $file) {
|
if(! -e $file) {
|
||||||
open FILE, ">", $file or die "can't create $file";
|
open FILE, ">", $file or die "can't create $file";
|
||||||
close FILE;
|
close FILE;
|
||||||
|
|
Loading…
Add table
Reference in a new issue