/[wait]/trunk/lib/WAIT/Table.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/WAIT/Table.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 41 by laperla, Mon Nov 13 20:25:49 2000 UTC revision 77 by laperla, Mon Apr 8 21:00:08 2002 UTC
# Line 4  Line 4 
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: Sun Nov 12 17:51:56 2000  # Last Modified On: Wed Jan 23 14:15:15 2002
8  # Language        : CPerl  # Language        : CPerl
9  # Update Count    : 148  # 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
# Line 381  sub open { Line 381  sub open {
381      }      }
382      require WAIT::InvertedIndex;      require WAIT::InvertedIndex;
383    }    }
384    
385      $self->getlock($self->{mode});
386    
387    unless (defined $self->{dbh}) {    unless (defined $self->{dbh}) {
388      if ($USE_RECNO) {      if ($USE_RECNO) {
389        $self->{dbh} = tie(@{$self->{db}}, 'DB_File', $file,        $self->{dbh} = tie(@{$self->{db}}, 'DB_File', $file,
# Line 392  sub open { Line 395  sub open {
395      }      }
396    }    }
397        
   $self->getlock($self->{mode});  
398        
399    $self;    $self;
400  }  }
# Line 595  sub set { Line 597  sub set {
597      warn "Cannot set iattr[$iattr] without write lock. Nothing done";      warn "Cannot set iattr[$iattr] without write lock. Nothing done";
598      return;      return;
599    }    }
600    
601      # in the rare case that they haven't written a single record yet, we
602      # make sure, the inverted inherits our $self->{mode}:
603      defined $self->{db} or $self->open;
604    
605    for my $att (keys %{$self->{inverted}}) {    for my $att (keys %{$self->{inverted}}) {
606      if ($] > 5.003) {         # avoid bug in perl up to 5.003_05      if ($] > 5.003) {         # avoid bug in perl up to 5.003_05
607        my $idx;        my $idx;
# Line 718  sub getlock { Line 725  sub getlock {
725      return $self if $self->{read_lock};      return $self if $self->{read_lock};
726    
727      # Get the preliminary write lock to protect the directory      # Get the preliminary write lock to protect the directory
728      # operations.  If we already have a write lock, it will go.      # operations.
729    
730      $self->{write_lock} ||= $lockmgr->lock($self->{file} . '/write')      my $write_lock = $lockmgr->lock($self->{file} . '/read/write')
731        or die "Can't lock '$self->{file}/write'";        or die "Can't lock '$self->{file}/read/write'";
732    
733      # Find a new read slot.  Maybe the plain file would be better?      # Find a new read slot.  Maybe the plain file would be better?
734      my $id = time;      my $id = time;
# Line 733  sub getlock { Line 740  sub getlock {
740        or die "Can't lock '$lockdir/$id'";        or die "Can't lock '$lockdir/$id'";
741    
742      # We are a reader now. So we release the write lock      # We are a reader now. So we release the write lock
743      $self->{write_lock}->release;      $write_lock->release;
     delete $self->{write_lock};  
744    }    }
745    return $self;    return $self;
746  }  }

Legend:
Removed from v.41  
changed lines
  Added in v.77

  ViewVC Help
Powered by ViewVC 1.1.26