INN commit: branches/2.5/frontends (pullnews.in)

INN Commit rra at isc.org
Sun Jan 23 10:26:30 UTC 2011


    Date: Sunday, January 23, 2011 @ 02:26:30
  Author: iulius
Revision: 9163

pullnews was not properly counting the number of bytes downloaded.
It was not resetting the count between newsgroups; consequently,
the bytes count was only right for the first newsgroup.

Thanks to Edmund H. Ramm for the bug report.

Modified:
  branches/2.5/frontends/pullnews.in

-------------+
 pullnews.in |   20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

Modified: pullnews.in
===================================================================
--- pullnews.in	2011-01-23 10:24:23 UTC (rev 9162)
+++ pullnews.in	2011-01-23 10:26:30 UTC (rev 9163)
@@ -558,6 +558,7 @@
     my ($prevDate,$prevHigh) = @{$shash->{$group}};
     my ($narticles,$first,$last,$name) = $fromServer->group($group);
     my $count = 0;
+    my $len = 0;                 # Received article length (bytes) (for stats).
     my $code;
     my $startTime = time;
     my ($prevRefused, $prevRejected) = ($info{refused}, $info{rejected});
@@ -642,7 +643,7 @@
             my $xref = 0;
             my $headers = 1;
             my $idx;
-            my $len = 0;                 # Received article length (bytes) (for stats).
+            my $line_len = 0;
             my $tx_len = 0;              # Transmitted article length (bytes) (for rnews).
             my @header_nums_to_go = ();
             my $match_all_hdrs = 1;      # Assume no headers to match.
@@ -651,8 +652,12 @@
             my $curr_hdr = '';
 
             for ($idx = 0 ; $idx < @{$article} ; $idx++) {
-                $len += length($article->[$idx]);
-                $tx_len += length($article->[$idx]);
+                $line_len = length($article->[$idx]);
+                $len += $line_len;
+                $tx_len += $line_len;
+                $info{server}->{$server}->{bytes} += $line_len;
+                $info{bytes} += $line_len;
+
                 next if not $headers;
 
                 $curr_hdr = lc($1) if $article->[$idx] =~ /^([^:[:blank:]]+):/;
@@ -723,7 +728,9 @@
                     print STDERR "Fixing bad header line[$idx]-1: $article->[$idx-1]" if $idx > 0;
                     print STDERR "Fixing bad header line[$idx]::: $article->[$idx]";
                     print STDERR "Fixing bad header line[$idx]+1: $article->[$idx+1]";
-                    $tx_len -= length($article->[$idx])-1;
+                    # Do not use $line_len here because $article->[$idx] has been modified
+                    # since the length was computed.
+                    $tx_len -= length($article->[$idx]) - 1;
                     $article->[$idx] = "\n";
                 }
 
@@ -763,8 +770,6 @@
             }
 
             $pulled->{$server}->{$group}++;
-            $info{server}->{$server}->{bytes} += $len;
-            $info{bytes} += $len;
 
             if ($skip_due_to_hdrs) {
                 print LOG "m" unless $quiet;
@@ -873,8 +878,7 @@
     } else {
         printf LOG "%s article%s retrieved in %d seconds (%d bytes, %d cps)\n",
                 $count, ($count == 1 ? "" : "s"), $elapsed_time,
-                $info{server}->{$server}->{bytes},
-                int($info{server}->{$server}->{bytes}*100/$elapsed_time)/100;
+                $len, int($len*100/$elapsed_time)/100;
     }
     return 1;
 }




More information about the inn-committers mailing list