fiz strange carp errors on startup with no route_*_cache files
authorDirk Koopman <djk@tobit.co.uk>
Sun, 15 Jan 2023 14:46:18 +0000 (14:46 +0000)
committerDirk Koopman <djk@tobit.co.uk>
Sun, 15 Jan 2023 14:46:18 +0000 (14:46 +0000)
Changes
perl/Route/Node.pm
perl/Route/User.pm

diff --git a/Changes b/Changes
index 9c6ffd41ca26325e1cb55856e92abb992eb37a3d..a0785510da5310c96e7251f3a04f77854e0bbbf3 100644 (file)
--- 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).
index 630db0468cc5c129908069b6765fc1fef6efe33f..af01a1d22d47ce199478c7ac9e394c7783b2c55c 100644 (file)
@@ -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;;
index d9d5249c459d21c5ade0bd143134af3657b49efe..2c988f1dcb950b9d4c2880c139cb08b21019a3a3 100644 (file)
@@ -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;