/[wait]/cvs-head/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 /cvs-head/lib/WAIT/Table.pm

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

revision 30 by ulpfr, Sat Nov 11 17:21:28 2000 UTC revision 31 by laperla, Sun Nov 12 01:26:10 2000 UTC
# Line 405  sub open { Line 405  sub open {
405      return $self if $self->{write_lock};      return $self if $self->{write_lock};
406            
407      # If we actually want to write we must check if there are any readers      # If we actually want to write we must check if there are any readers
408        local *DIR;
409      opendir DIR, $lockdir or      opendir DIR, $lockdir or
410        die "Could not opendir '$lockdir': $!";        die "Could not opendir '$lockdir': $!";
411      for my $lockfile (grep { -f "$lockdir/$_" } readdir DIR) {      for my $lockfile (grep { -f "$lockdir/$_" } readdir DIR) {
# Line 419  sub open { Line 420  sub open {
420          die "Cannot write table '$file' while it's in use";          die "Cannot write table '$file' while it's in use";
421        }        }
422      }      }
423        closedir DIR;
424    } else {    } else {
425      # this is a hack.  We do not check for reopening ...      # this is a hack.  We do not check for reopening ...
426      return $self if $self->{read_lock};      return $self if $self->{read_lock};
# Line 609  sub delete { Line 611  sub delete {
611  }  }
612    
613  sub unpack {  sub unpack {
614    my $self = shift;    my($self, $tuple) = @_;
615    my $tuple = shift;  
616    return unless defined $tuple;    unless (defined $tuple){
617        # require Carp; # unfortunately gives us "bizarre copy...." :-(((((
618        warn("Debug: somebody called unpack without argument tuple!");
619        return;
620      }
621    
622    my $att;    my $att;
623    my @result;    my @result;
# Line 626  sub unpack { Line 632  sub unpack {
632  sub set {  sub set {
633    my ($self, $iattr, $value) = @_;    my ($self, $iattr, $value) = @_;
634        
635    unless ($self->{write_lock}) {    unless ($self->{write_lock}){
636      die "Cannot set attribute $iattr without having a write lock. Nothing done";      warn "Cannot set iattr[$iattr] without write lock. Nothing done";
637        return;
638    }    }
639    for my $att (keys %{$self->{inverted}}) {    for my $att (keys %{$self->{inverted}}) {
640      if ($] > 5.003) {         # avoid bug in perl up to 5.003_05      if ($] > 5.003) {         # avoid bug in perl up to 5.003_05
# Line 649  sub close { Line 656  sub close {
656    if (exists $self->{'access'}) {    if (exists $self->{'access'}) {
657      eval {$self->{'access'}->close}; # dont bother if not opened      eval {$self->{'access'}->close}; # dont bother if not opened
658    }    }
659    for (values %{$self->{indexes}}) {    if ($WAIT::Index::VERSION) {
660      require WAIT::Index;      for (values %{$self->{indexes}}) {
661      $_->close();        $_->close();
662        }
663    }    }
664    if (defined $self->{inverted}) {    if (defined $self->{inverted} && $WAIT::InvertedIndex::VERSION) {
665      require WAIT::InvertedIndex;      # require WAIT::InvertedIndex; Uli: we can avoid closing indexes:
666        # if WAIT::InvertedIndex has not been loaded, they cannot have
667        # been altered so far
668      my $att;      my $att;
669      for $att (keys %{$self->{inverted}}) {      for $att (keys %{$self->{inverted}}) {
670        if ($] > 5.003) {         # avoid bug in perl up to 5.003_05        if ($] > 5.003) {         # avoid bug in perl up to 5.003_05

Legend:
Removed from v.30  
changed lines
  Added in v.31

  ViewVC Help
Powered by ViewVC 1.1.26