if (open(LOCK, "> $DCONF->{admin_dir}/locks/$filename")) {
eval 'flock LOCK, 2; seek LOCK, 0, 2;';
print LOCK "$process\n$ip\n$time\n";
eval 'flock LOCK, 8;';
close (LOCK);
umask($mask);
if (open(LOCK, "< $DCONF->{admin_dir}/locks/$filename")) {
my @file = <LOCK>;
close (LOCK);
next if defined $file[3];
my $process_file = $file[0]; chomp $process_file;
my $ip_file = $file[1]; chomp $ip_file;
my $time_file = $file[2]; chomp $time_file;
return 1 if $process_file == $process && $ip_file eq $ip;
}
} else {
umask($mask);
error_message("File Locking Error", "Could not write to file [$filename] in 'locks' directory");
}
}
}
###
### directory_file_based_file_unlock
###
### Unlock file with this scheme
###
sub directory_file_based_file_unlock {
my ($files) = @_;
my @files = @{ $files };
foreach my $file (@files) {
performance_string("# LOCK: Unlock $file") if $GLOBAL_OPTIONS->{performance_monitoring};
$PARAMS->{files_unlocked}++;
if ($file eq "*") {
unlink("$DCONF->{admin_dir}/locks/GLOBAL") || log_error("src-board-subs-common", "unlock", "Could not remove file 'GLOBAL' from locks directory: $!");
} else {
$file =~ m|(.*)/(.*)|; my $dir = $1; my $filenm = $2;
if (!unlink("$DCONF->{admin_dir}/locks/$filenm")) {
if (-e "$DCONF->{admin_dir}/locks/$filenm") {
log_error("locking.pl", "directory_file_based_file_unlock", "Could not remove file '$filenm' from locks directory: [$!]");
if ($GLOBAL_OPTIONS->{'lockerror_disable'} == 1 || $GLOBAL_OPTIONS->{'lockerror_disable'} eq "") {
open (BACKUPS, ">$DCONF->{admin_dir}/backups/QUOTA.txt");
print BACKUPS time, "\n";
print BACKUPS escape("Unlocking file $filenm -- could not remove file from $DCONF->{admin_dir}/locks because of system error [$!]. If this says 'Permission Denied' you need to fix your permissions as directed at <A HREF=http://www.discusware.com/support/resources/windows/nt_permissions.html>this page</A>. If allowed to continue this way, your disk quota will fill up quickly, and your users will get 'File Locking Errors' more often than they should"), "\n";