🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
8 messages
8 total messages Started by Edmund H. Ramm Tue, 16 Nov 2010 16:43
[INN] pullnews byte count
#83682
Author: Edmund H. Ramm
Date: Tue, 16 Nov 2010 16:43
13 lines
1531 bytes
   After having pulled all articles of a group pullnews prints,
among other statistics, a byte count. This byte count only
represents the number of bytes downloaded for said group after the
first group, because it is the cumulative (and global)
$info{server}->{$server}->{bytes} instead of the local $len.

   Feature or bug?

   Eddi ._._.
-- 
      e-mail: dk3uz AT arrl DOT net  |  AMPRNET: dk3uz@db0hht.ampr.org
      If replying to a Usenet article, please use above e-mail address.
               Linux/m68k, the best U**x ever to hit an Atari!
Re: [INN] pullnews byte count
#83741
Author: Julien ÉLIE
Date: Tue, 16 Nov 2010 19:49
98 lines
4768 bytes
Hi Edmund,

>   After having pulled all articles of a group pullnews prints,
> among other statistics, a byte count. This byte count only
> represents the number of bytes downloaded for said group after the
> first group, because it is the cumulative (and global)
> $info{server}->{$server}->{bytes} instead of the local $len.

"44 articles retrieved in 3 seconds (103412 bytes, 34470 cps)"


> Feature or bug?

It's a bug.  Thanks for having reported it!


Here is a patch:


Index: pullnews.in
===================================================================
--- pullnews.in (révision 9135)
+++ pullnews.in (copie de travail)
@@ -565,6 +570,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});
@@ -649,7 +655,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.
@@ -658,8 +664,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:]]+):/;
@@ -730,7 +740,7 @@
                     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;
+                    $tx_len -= $line_len - 1;
                     $article->[$idx] = "\n";
                 }

@@ -770,8 +780,6 @@
             }

             $pulled->{$server}->{$group}++;
-            $info{server}->{$server}->{bytes} += $len;
-            $info{bytes} += $len;

             if ($skip_due_to_hdrs) {
                 print LOG "m" unless $quiet;
@@ -880,8 +888,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;
 }





-- 
Julien ÉLIE

« Sol lucet omnibus. » 
Re: [INN] pullnews byte count
#83681
Author: Edmund H. Ramm
Date: Wed, 17 Nov 2010 00:27
26 lines
1980 bytes
Cher ami Julien,

In <ibun7q$kt2$1@news.trigofacile.com> =?Windows-1252?Q?Julien_=C9LIE?= <iulius@nom-de-mon-site.com.invalid> writes:

>> [...]
> It's a bug.  Thanks for having reported it!
> Here is a patch:
> [...]

   thanks, your patch works, also the achieved bandwidths are more
realistic now.

> « Sol lucet omnibus. » 

   Hopefully enough to make all bugs easier to find.  :-)

   E.g. the flag '-k 50' gets only honoured when there are >50
articles in one group. If all groups have <50 articles respectively,
the config file is only updated after all groups have been pulled,
i.e. when pullnews terminates.

   slt, Eddi ._._.
-- 
      e-mail: dk3uz AT arrl DOT net  |  AMPRNET: dk3uz@db0hht.ampr.org
      If replying to a Usenet article, please use above e-mail address.
               Linux/m68k, the best U**x ever to hit an Atari!
Re: [INN] pullnews byte count
#83684
Author: Julien ÉLIE
Date: Wed, 17 Nov 2010 19:29
81 lines
4222 bytes
Hi Edmund,

>> Here is a patch:
>> [...]
>
>   thanks, your patch works

Unless you're using rnews, in which case the new byte count might be
wrong...  We should keep length($article->[$idx]) at this place, so
that $tx_len is correctly updated.

+  # 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";



>   E.g. the flag '-k 50' gets only honoured when there are >50
> articles in one group. If all groups have <50 articles respectively,
> the config file is only updated after all groups have been pulled,
> i.e. when pullnews terminates.

You're right.  This patch should do the trick.
I also renamed the global $count variable because I do not like much
two variables named the same way (one global and another one local).


--- pullnews.in (révision 9149)
+++ pullnews.in (copie de travail)
@@ -302,14 +302,14 @@

 open(FILE, "<$groupFile") || die "can't open group file $groupFile\n";

-my $count = 0;
+my $array_order = 0;
 while (<FILE>) {
     next if m!^\s*\#! || m!^\s*$!;

     if (m!^(\S+)(\s+(\S+)\s+(\S+))?\s*$!) {
         $sname = $1;
         $servers->{$sname} = {};
-        $servers->{$sname}->{_order} = $count++;
+        $servers->{$sname}->{_order} = $array_order++;
         $passwd{$sname} = [ $3, $4 ] if defined $3 and $3 ne "";
     } elsif (m!^\s+(\S+)\s+(\d+)\s+(\d+)!) {
         my ($group,$date,$high) = ($1,$2,$3);
@@ -330,6 +330,7 @@
 die "No servers!\n" if ! @servers;

 my $localcxn;
+my $art_total_count = 0;    # The number of articles transferred during the 
session.

 if ( not $rnews ) {
     print LOG "Connecting to downstream host: $localServer " .
@@ -621,6 +622,7 @@
         last if defined $maxArts and $count >= $maxArts;
         last if defined $opt_f and $count >= $toget;
         $count++;
+        $art_total_count++;
         sleep $opt_z if defined $opt_z and $count > 1;
         # "Optimized mode" -- check if the article is wanted *before* downloading 
it.
         if (defined $opt_O) {
@@ -868,7 +870,7 @@
             printf LOG ("\nDEBUGGING $i %s %s\n", $fromServer->code(),
                         $fromServer->message()) if $debug >= 2;
         }
-        saveConfig() if $checkPoint and ($count % $checkPoint) == 0;
+        saveConfig() if $checkPoint and ($art_total_count % $checkPoint) == 0;
         print LOG "\n" if (!$quiet && (($count % $progressWidth) == 0));
         last if defined $opt_S and time >= $^T+$opt_S;
     }


-- 
Julien ÉLIE

« Ira furor breuis est. » (Horace) 
Re: [INN] pullnews byte count
#83687
Author: Edmund H. Ramm
Date: Thu, 18 Nov 2010 00:00
59 lines
3015 bytes
Bjr Julien,

In <ic1af4$irk$1@news.trigofacile.com> =?Windows-1252?Q?Julien_=C9LIE?= <iulius@nom-de-mon-site.com.invalid> writes:

>>   E.g. the flag '-k 50' gets only honoured when there are >50
>> articles in one group.
>> [...]

> You're right.  This patch should do the trick.
> [...]

   Well...

Hunk #1 FAILED at 302.
Hunk #2 succeeded at 311 (offset -19 lines).
Hunk #3 succeeded at 599 with fuzz 2 (offset -23 lines).
Hunk #4 succeeded at 815 (offset -55 lines).
1 out of 4 hunks FAILED -- saving rejects to file pullnews.rej

pullnews.rej:
-----
***************
*** 302,315 ****
  
  open(FILE, "<$groupFile") || die "can't open group file $groupFile\n";
  
- my $count = 0;
  while (<FILE>) {
      next if m!^\s*\#! || m!^\s*$!;
  
      if (m!^(\S+)(\s+(\S+)\s+(\S+))?\s*$!) {
          $sname = $1;
          $servers->{$sname} = {};
-         $servers->{$sname}->{_order} = $count++;
          $passwd{$sname} = [ $3, $4 ] if defined $3 and $3 ne "";
      } elsif (m!^\s+(\S+)\s+(\d+)\s+(\d+)!) {
          my ($group,$date,$high) = ($1,$2,$3);
--- 302,315 ----
  
  open(FILE, "<$groupFile") || die "can't open group file $groupFile\n";
  
+ my $array_order = 0;
  while (<FILE>) {
      next if m!^\s*\#! || m!^\s*$!;
  
      if (m!^(\S+)(\s+(\S+)\s+(\S+))?\s*$!) {
          $sname = $1;
          $servers->{$sname} = {};
+         $servers->{$sname}->{_order} = $array_order++;
          $passwd{$sname} = [ $3, $4 ] if defined $3 and $3 ne "";
      } elsif (m!^\s+(\S+)\s+(\d+)\s+(\d+)!) {
          my ($group,$date,$high) = ($1,$2,$3);
-----

   HTH, Eddi ._._.
-- 
      e-mail: dk3uz AT arrl DOT net  |  AMPRNET: dk3uz@db0hht.ampr.org
      If replying to a Usenet article, please use above e-mail address.
               Linux/m68k, the best U**x ever to hit an Atari!
Re: [INN] pullnews byte count
#83689
Author: Julien ÉLIE
Date: Thu, 18 Nov 2010 08:31
20 lines
1969 bytes
Hi Edmund,

> Hunk #1 FAILED at 302.

Just change the name of these two occurrences of $count to $array_order,
near line 300:

> - my $count = 0;
> - $servers->{$sname}->{_order} = $count++;

> + my $array_order = 0;
> + $servers->{$sname}->{_order} = $array_order++;

-- 
Julien ÉLIE

« -- Chef ! On vient !
  -- On se met en carré ?
  -- Non ! En bosquet ! » (Astérix) 
Re: [INN] pullnews byte count
#83690
Author: Edmund H. Ramm
Date: Thu, 18 Nov 2010 20:20
44 lines
2722 bytes
Bsr Julien,

In <ic2o9q$73o$1@news.trigofacile.com> =?Windows-1252?Q?Julien_=C9LIE?= <iulius@nom-de-mon-site.com.invalid> writes:

>> Hunk #1 FAILED at 302.
> Just change the name of these two occurrences of $count to $array_order,
> near line 300:

>> [...]
>> - $servers->{$sname}->{_order} = $count++;

   That's the problem. The above line doesn't exist in my pullnews
version (Debian Lenny). The corresponding block of code looks like
this:

-----
while (<FILE>) {
    next if m!^\s*\#! || m!^\s*$!;

    if (m!^(\S+)(\s+(\S+)\s+(\S+))?\s*$!) {
        $sname = $1;
        $servers->{$sname} = {};
        $passwd{$sname} = [ $3, $4 ] if defined $3 and $3 ne "";
    } elsif (m!^\s+(\S+)\s+(\d+)\s+(\d+)!) {
        my ($group,$date,$high) = ($1,$2,$3);
        $servers->{$sname}->{$group} = [ $date, $high ];
    } elsif (m!^\s+(\S+)\s*$!) {
        # Assume this is a new group.
        my ($group,$date,$high) = ($1,0,0);
        print LOG "Looking for new group $group on $sname\n" unless $quiet;
        $servers->{$sname}->{$group} = [ $date, $high ];
    } else {
        die "Fatal error in $groupFile: $.: $_\n";
    }
}
-----

   Does this make any sense to you?

   slt, Eddi ._._.
-- 
      e-mail: dk3uz AT arrl DOT net  |  AMPRNET: dk3uz@db0hht.ampr.org
      If replying to a Usenet article, please use above e-mail address.
               Linux/m68k, the best U**x ever to hit an Atari!
Re: [INN] pullnews byte count
#83691
Author: Julien ÉLIE
Date: Thu, 18 Nov 2010 23:02
25 lines
2189 bytes
Hi Edmund,

>>> - $servers->{$sname}->{_order} = $count++;
>
>   That's the problem. The above line doesn't exist in my pullnews
> version (Debian Lenny).

Ah, OK.  It is INN 2.4.5.  That feature does not exist in the pullnews
shipped with INN 2.4.5, so you can do without hunk #1.

The order was introduced later.  Commit 8217:

  + Use admin-specified ordering of servers in config file (useful when using
    timeouts and some servers are faster/preferred).


> The corresponding block of code looks like this:

It is fine.  Just keep it unchanged.

-- 
Julien ÉLIE

« I don't worry about terrorism.  I was married for two years. » (Sam Kinison) 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads