version 1.328, 2006/05/18 02:32:06
|
version 1.330, 2006/05/18 19:57:59
|
Line 1063 sub _do_hash_untie {
|
Line 1063 sub _do_hash_untie {
|
} |
} |
# Apparently just no lock file yet. Make one |
# Apparently just no lock file yet. Make one |
open($sym,">>$file_prefix.db.lock"); |
open($sym,">>$file_prefix.db.lock"); |
} |
} |
|
# Do a shared lock |
|
if (!&flock_sym(LOCK_SH)) { return undef; } |
|
# If this is compressed, we will actually need an exclusive lock |
|
if (-e "$file_prefix.db.gz") { |
|
if (!&flock_sym(LOCK_EX)) { return undef; } |
|
} |
} elsif ($how eq &GDBM_WRCREAT()) { |
} elsif ($how eq &GDBM_WRCREAT()) { |
# We are writing |
# We are writing |
open($sym,">>$file_prefix.db.lock"); |
open($sym,">>$file_prefix.db.lock"); |
# Writing needs exclusive lock |
# Writing needs exclusive lock |
$lock_type=LOCK_EX; |
if (!&flock_sym(LOCK_EX)) { return undef; } |
} else { |
} else { |
&logthis("Unknown method $how for $file_prefix"); |
&logthis("Unknown method $how for $file_prefix"); |
die(); |
die(); |
} |
} |
# If this is compressed, we will also need an exclusive lock |
|
if (-e "$file_prefix.db.gz") { $lock_type=LOCK_EX; } |
|
# Okay, try to obtain the lock we want |
|
my $failed=0; |
|
eval { |
|
local $SIG{__DIE__}='DEFAULT'; |
|
local $SIG{ALRM}=sub { |
|
$failed=1; |
|
die("failed lock"); |
|
}; |
|
alarm($lond_max_wait_time); |
|
flock($sym,$lock_type); |
|
alarm(0); |
|
}; |
|
if ($failed) { |
|
$! = 100; # throwing error # 100 |
|
return undef; |
|
} |
|
# The file is ours! |
# The file is ours! |
# If it is archived, un-archive it now |
# If it is archived, un-archive it now |
if (-e "$file_prefix.db.gz") { |
if (-e "$file_prefix.db.gz") { |
Line 1105 sub _do_hash_untie {
|
Line 1093 sub _do_hash_untie {
|
return &_do_hash_tie($file_prefix,$namespace,$how,$loghead,$what); |
return &_do_hash_tie($file_prefix,$namespace,$how,$loghead,$what); |
} |
} |
|
|
|
sub flock_sym { |
|
my ($lock_type)=@_; |
|
my $failed=0; |
|
eval { |
|
local $SIG{__DIE__}='DEFAULT'; |
|
local $SIG{ALRM}=sub { |
|
$failed=1; |
|
die("failed lock"); |
|
}; |
|
alarm($lond_max_wait_time); |
|
flock($sym,$lock_type); |
|
alarm(0); |
|
}; |
|
if ($failed) { |
|
$! = 100; # throwing error # 100 |
|
return undef; |
|
} else { |
|
return 1; |
|
} |
|
} |
|
|
sub _locking_hash_untie { |
sub _locking_hash_untie { |
my ($hashref) = @_; |
my ($hashref) = @_; |
my $result = untie(%$hashref); |
my $result = untie(%$hashref); |
Line 2303 sub token_auth_user_file_handler {
|
Line 2312 sub token_auth_user_file_handler {
|
if (open(ENVIN,$perlvar{'lonIDsDir'}.'/'. |
if (open(ENVIN,$perlvar{'lonIDsDir'}.'/'. |
$session.'.id')) { |
$session.'.id')) { |
while (my $line=<ENVIN>) { |
while (my $line=<ENVIN>) { |
if ($line=~ m|userfile\.\Q$fname\E\=|) { $reply="ok\n"; } |
my ($envname)=split(/=/,$line,2); |
|
$envname=&unescape($envname); |
|
if ($envname=~ m|^userfile\.\Q$fname\E|) { $reply="ok\n"; } |
} |
} |
close(ENVIN); |
close(ENVIN); |
&Reply($client, $reply, "$cmd:$tail"); |
&Reply($client, $reply, "$cmd:$tail"); |