4 |
# Author : Ulrich Pfeifer |
# Author : Ulrich Pfeifer |
5 |
# Created On : Thu Aug 8 13:05:10 1996 |
# Created On : Thu Aug 8 13:05:10 1996 |
6 |
# Last Modified By: Ulrich Pfeifer |
# Last Modified By: Ulrich Pfeifer |
7 |
# Last Modified On: Tue Nov 14 16:19:17 2000 |
# Last Modified On: Wed Jan 23 14:15:15 2002 |
8 |
# Language : CPerl |
# Language : CPerl |
9 |
# Update Count : 149 |
# Update Count : 152 |
10 |
# Status : Unknown, Use with caution! |
# Status : Unknown, Use with caution! |
11 |
# |
# |
12 |
# Copyright (c) 1996-1997, Ulrich Pfeifer |
# Copyright (c) 1996-1997, Ulrich Pfeifer |
720 |
return $self if $self->{read_lock}; |
return $self if $self->{read_lock}; |
721 |
|
|
722 |
# Get the preliminary write lock to protect the directory |
# Get the preliminary write lock to protect the directory |
723 |
# operations. If we already have a write lock, it will go. |
# operations. |
724 |
|
|
725 |
$self->{write_lock} ||= $lockmgr->lock($self->{file} . '/write') |
my $write_lock = $lockmgr->lock($self->{file} . '/read/write') |
726 |
or die "Can't lock '$self->{file}/write'"; |
or die "Can't lock '$self->{file}/read/write'"; |
727 |
|
|
728 |
# Find a new read slot. Maybe the plain file would be better? |
# Find a new read slot. Maybe the plain file would be better? |
729 |
my $id = time; |
my $id = time; |
735 |
or die "Can't lock '$lockdir/$id'"; |
or die "Can't lock '$lockdir/$id'"; |
736 |
|
|
737 |
# We are a reader now. So we release the write lock |
# We are a reader now. So we release the write lock |
738 |
$self->{write_lock}->release; |
$write_lock->release; |
|
delete $self->{write_lock}; |
|
739 |
} |
} |
740 |
return $self; |
return $self; |
741 |
} |
} |