cnfsstat -a warns about uninitialized value for new buffer

Julien ÉLIE julien at trigofacile.com
Sun Oct 24 14:57:08 UTC 2010


Hi Florian,

Thanks again for your bug report.


> I just created new CNFS buffers and noticed that 'cnfsstat -a' will spit
> warnings about uninitialized values when trying to compute the oldest
> article in those yet-unused buffers:
>
> Buffer BUFF09, size:  2.00 GBytes, position:  80.0 kBytes  0.00 cycles
>   Newest: 2010-10-20 18:29:10,    0 days,  0:09:33 ago
> Use of uninitialized value $t in localtime at /server/feeder/server/bin/cnfsstat line 306.
> Use of uninitialized value $t in subtraction (-) at /server/feeder/server/bin/cnfsstat line 310.
>   Oldest: 1970-01-01  1:00:00, 14902 days, 16:38:43 ago
>
> Apparently, $oldart is undef in print_cycbuff_head, whereas make_time
> assumes its argument to be numerical. A quick solution is below, but you
> may want to do something similar in the call to make_time instead...

I think we should drop the "1970-01-01" output.

Suggestion:

Buffer BUFF09, size:  2.00 GBytes, position:  80.0 kBytes  0.00 cycles
  Created: 2010-10-20 18:29:10,    0 days,  0:09:33 ago
  No oldest article

and of course the usual output "Newest"/"Oldest" when $oldart exists.


--- cnfsstat.in (révision 9112)
+++ cnfsstat.in (copie de travail)
@@ -290,12 +290,21 @@
     print " Buffer $name, size: ", &human_readable($len, 4);
     print ", position: ", &human_readable($free, 4);
     printf("  %.2f cycles\n", $cyclenum + Math::BigFloat->new($free) / Math::BigFloat->new($len));
+
     my ($when, $ago) = &make_time($update);
-    print "  Newest: $when, $ago ago\n";
+    if (defined $oldart) {
+        print "  Newest: $when, $ago ago\n";

-    if ($opt_a) {
-       my ($when, $ago) = &make_time($oldart);
-       print "  Oldest: $when, $ago ago\n";
+        if ($opt_a) {
+            my ($when, $ago) = &make_time($oldart);
+            print "  Oldest: $when, $ago ago\n";
+        }
+    } else {
+        print "  Created: $when, $ago ago\n";
+
+        if ($opt_a) {
+            print "  No oldest article\n";
+        }
     }
 }



OK for you?

-- 
Julien ÉLIE

« Il ne faut jamais gifler un sourd : il perd la moitié du plaisir.
  Il sent la gifle mais il ne l'entend pas. » (Georges Courteline) 




More information about the inn-workers mailing list