From e84886994919a824161f95f0bd0f0e0cae0c5050 Mon Sep 17 00:00:00 2001 From: Dirk Koopman Date: Sun, 15 Jan 2023 14:46:18 +0000 Subject: [PATCH] fiz strange carp errors on startup with no route_*_cache files --- Changes | 2 ++ perl/Route/Node.pm | 6 +++--- perl/Route/User.pm | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Changes b/Changes index 9c6ffd41..a0785510 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,5 @@ +15Jan23======================================================================= +1. Fix strange errors for carp on missing route_*_cache files on startup. 14Jan23======================================================================= 1. Fixed route PC11 promotions so that a new PC61 is actually generated and also sent instead of the original PC11 (to PC61 capable nodes). diff --git a/perl/Route/Node.pm b/perl/Route/Node.pm index 630db046..af01a1d2 100644 --- a/perl/Route/Node.pm +++ b/perl/Route/Node.pm @@ -411,7 +411,7 @@ sub write_cache } }; if (!$@ && @s) { - my $fh = IO::File->new(">$cachefn") or carp("writing $cachefn $!"); + my $fh = IO::File->new(">$cachefn") or dbg("Route::Node: Error writing $cachefn $!"), return; print $fh "$_" for (sort @s); $fh->close; } else { @@ -431,11 +431,11 @@ sub read_cache my $ta = [ gettimeofday ]; my $count; - my $fh = IO::File->new("$cachefn") or carp("reading $cachefn $!"); + my $fh = IO::File->new("$cachefn") or dbg("Route::Node ERROR reading $cachefn $!"), return; while (my $l = <$fh>) { chomp $l; my ($k, $v) = split /:/, $l, 2; - $list{$k} = bless $json->decode($v) or carp("json error decoding '$v'"); + $list{$k} = bless $json->decode($v) or carp("Route::Node json error $! decoding '$v'"), next; ++$count; } $fh->close if $fh;; diff --git a/perl/Route/User.pm b/perl/Route/User.pm index d9d5249c..2c988f1d 100644 --- a/perl/Route/User.pm +++ b/perl/Route/User.pm @@ -113,7 +113,7 @@ sub write_cache } }; if (!$@ && @s) { - my $fh = IO::File->new(">$cachefn") or carp("writing $cachefn $!"); + my $fh = IO::File->new(">$cachefn") or dbg("Route::User: ERROR writing $cachefn $!"), return; print $fh $_ for (sort @s); $fh->close; } else { @@ -132,11 +132,11 @@ sub read_cache my $ta = [ gettimeofday ]; my $count; - my $fh = IO::File->new("$cachefn") or carp("reading $cachefn $!"); + my $fh = IO::File->new("$cachefn") or dbg("Route::User: ERROR reading $cachefn $!"), return; while (my $l = <$fh>) { chomp $l; my ($k, $v) = split /:/, $l, 2; - $list{$k} = bless $json->decode($v) or carp("json error decoding '$v'"); + $list{$k} = bless $json->decode($v) or dbg("Route::User: Error json error $! decoding '$v'"), next; ++$count; } $fh->close if $fh; -- 2.43.0