summaryrefslogtreecommitdiff
path: root/Echolot
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2004-05-18 00:39:03 +0000
committerPeter Palfrader <peter@palfrader.org>2004-05-18 00:39:03 +0000
commit107b086717ec5d9a31fefdbd038d7b6ce900f557 (patch)
tree4eda4e15f9e850069c27c354bfe56593b6816a30 /Echolot
parentfc456a6746594811e59e2555515913d31722676c (diff)
Handle situations better in which a ping receives when the key already is expired.
Diffstat (limited to 'Echolot')
-rw-r--r--Echolot/Storage/File.pm19
1 files changed, 14 insertions, 5 deletions
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<get_ping_fh>( I<$remailer_addr>, I<$type>, I<$key>, I<$direction> )
+=item $storage->B<get_ping_fh>( 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 $<oknodo> 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 ();