From 107b086717ec5d9a31fefdbd038d7b6ce900f557 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Tue, 18 May 2004 00:39:03 +0000 Subject: Handle situations better in which a ping receives when the key already is expired. --- Echolot/Storage/File.pm | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'Echolot') diff --git a/Echolot/Storage/File.pm b/Echolot/Storage/File.pm index 96dd8a7..0325458 100644 --- a/Echolot/Storage/File.pm +++ b/Echolot/Storage/File.pm @@ -403,15 +403,18 @@ sub pingdata_open($) { return 1; }; -=item $storage->B( I<$remailer_addr>, I<$type>, I<$key>, I<$direction> ) +=item $storage->B( I<$remailer_addr>, I<$type>, I<$key>, I<$direction>, I<$oknodo> ) Return the FH for the pingdata file of I<$remailer_addr>, I<$type>, I<$key>, and I<$direction>. +If $ is set, the absense of a defined filehandle does not cause it to +be opened/created. Instead -1 is returned. + Returns undef on error; =cut -sub get_ping_fh($$$$$) { - my ($self, $remailer_addr, $type, $key, $direction) = @_; +sub get_ping_fh($$$$$;$) { + my ($self, $remailer_addr, $type, $key, $direction, $oknodo) = @_; defined ($self->{'METADATA'}->{'addresses'}->{$remailer_addr}) or Echolot::Log::cluck("$remailer_addr does not exist in Metadata."), @@ -419,12 +422,15 @@ sub get_ping_fh($$$$$) { my $fh = $self->{'PING_FHS'}->{$remailer_addr}->{$type}->{$key}->{$direction}; - defined ($fh) or + unless (defined $fh) { + return -1 if (defined $oknodo && $oknodo); + $self->pingdata_open_one($remailer_addr, $type, $key), $fh = $self->{'PING_FHS'}->{$remailer_addr}->{$type}->{$key}->{$direction}; defined ($fh) or Echolot::Log::warn ("$remailer_addr; type=$type; key=$key has no assigned filehandle for $direction pings."), return undef; + } return $fh; }; @@ -507,7 +513,10 @@ sub get_pings($$$$$) { my @pings; - my $fh = $self->get_ping_fh($remailer_addr, $type, $key, $direction) or + my $fh = $self->get_ping_fh($remailer_addr, $type, $key, $direction, 1); + (defined $fh) or + Echolot::Log::cluck ("$remailer_addr; type=$type; key=$key has no assigned filehandle for out pings."), + ($fh == -1) and Echolot::Log::info ("$remailer_addr; type=$type; key=$key has no assigned filehandle for $direction pings (key has expired)."), return (); -- cgit v1.2.3