violent_unlock_file
set_master_lock
release_file
+ file_removed
);
%EXPORT_TAGS = (
# try do decrement the reference counter
#
- if (set_ref($filename,-1,$timeout)) {
+ if (set_ref($filename, -1, $timeout)) {
delete $LOCKED{$filename};
return 1;
}
1;
}
+sub w_file_removed ($) {
+ my $filename = shift;
+
+ unlink reffile($filename);
+ unlink lockfile($filename);
+ unlink lockfile(reffile($filename));
+ unlink masterlockfile($filename);
+}
+
################################################################################
#
# *n*x section (symlinks possible)
1;
}
+sub x_file_removed ($) {
+ release_file (shift);
+}
+
### sub w_simple_lock ($;$) ####################################################
### sub w_simple_unlock ($) ####################################################
#
my $timeout = shift || $Timeout;
my $lockfile = lockfile $filename;
- for (1..$timeout) {
+ for (0..$timeout) {
unlink $lockfile and return 1;
sleep(1);
}
my $timeout = shift || $Timeout;
my $lockfile = lockfile $filename;
- for (1..$timeout) {
+ for (0..$timeout) {
symlink $filename,$lockfile and return 1;
sleep(1);
}
unlink $reffile or return;
}
else {
- local $\="\n";
+ local $\;
sysopen (REF, $reffile, O_WRONLY | O_TRUNC | O_CREAT) or return;
print REF $old or do {
close REF;
unlink $reffile or return;
}
else {
- local $\="\n";
+ local $\;
sysopen (REF, $reffile, O_WRONLY | O_TRUNC | O_CREAT) or return;
print REF $old or do {
close REF;
my $reffile = reffile $filename;
my $old;
local *REF;
+ local $/;
- if (sysopen (REF, $reffile, O_RDONLY)) {
- local $/="\n";
- read REF, $old, -s $reffile;
- close REF;
- chomp $old;
- }
+ sysopen (REF, $reffile, O_RDONLY) or return 0;
+ $old = <REF>;
+ close REF;
# return value
- $old or 0;
+ $old;
}
################################################################################
*violent_unlock_file = \&x_violent_unlock_file;
*set_master_lock = \&x_set_master_lock;
*release_file = \&x_release_file;
+ *file_removed = \&x_file_removed;
*simple_lock = \&x_simple_lock;
*simple_unlock = \&x_simple_unlock;
*violent_unlock_file = \&w_violent_unlock_file;
*set_master_lock = \&w_set_master_lock;
*release_file = \&w_release_file;
+ *file_removed = \&w_file_removed;
*simple_lock = \&w_simple_lock;
*simple_unlock = \&w_simple_unlock;