Commit d2d3a749 authored by sikeda's avatar sikeda
Browse files

[-dev] (con'd 10266) Sympa::LockedFile::open(): Special mode "+" for pure...

[-dev] (con'd 10266) Sympa::LockedFile::open(): Special mode "+" for pure locking (not to open target file).


git-svn-id: https://subversion.renater.fr/sympa/branches/sympa-6.2-branch@10268 05aa8bb8-cd2b-0410-b1d7-8918dfa770ce
parent cfab756b
......@@ -64,10 +64,12 @@ sub open {
return undef;
}
unless ($self->SUPER::open($file, $mode)) {
Log::do_log('err', 'Failed opening %s: %s', $file, $!);
$lock->unlock; # make sure unlock to occur immediately.
return undef;
if ($mode ne '+') {
unless ($self->SUPER::open($file, $mode)) {
Log::do_log('err', 'Failed opening %s: %s', $file, $!);
$lock->unlock; # make sure unlock to occur immediately.
return undef;
}
}
$lock_of{$self + 0} = $lock; # register lock object, i.e. keep locking.
......@@ -78,7 +80,12 @@ sub close {
Log::do_log('debug2', '(%s)', @_);
my $self = shift;
my $ret = $self->SUPER::close;
my $ret;
if (defined $self->fileno) {
$ret = $self->SUPER::close;
} else {
$ret = 1;
}
croak 'Lock not found'
unless exists $lock_of{$self + 0};
......@@ -185,6 +192,9 @@ otherwise shared lock (C<LOCK_SH>).
Default is C<'E<lt>'>.
Additionally, a special mode C<'+'> will acquire exclusive lock
without opening file. In this case the file does not have to exist.
=back
Returns:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment