[3173] in SIPB bug reports
nntp.pl: expect timeouts too short
daemon@ATHENA.MIT.EDU (mhpower@stan.mit.edu)
Wed Sep 16 21:57:58 1992
Date: Wed, 16 Sep 1992 21:56:30 -0400
From: mhpower@stan.mit.edu
To: bug-sipb@Athena.MIT.EDU
/afs/sipb.mit.edu/contrib/perl/nntpfetch sometimes terminates with a
"No articles matched." error message when there are articles available
that should be retrieved, given the specified arguments.
This happens intermittently; sometimes running it again immediately,
with the same arguments, gives a series of "Saving ... in file"
messages rather than the error message.
Also, in one case, nntpfetch gave three "Saving ... in file" messages,
but the specified files were empty, even though they were created on a
UFS filesystem with no quotas and plenty of available space. At least
ten articles should have been retrieved (and, in fact, were, when the
same nntpfetch command was run again).
I think the problem is that the timeout_time values in the various
calls to expect are too short. The most critical one seems to be the
first one in the "fields" subroutine of nntp.pl. It issues an XHDR
command with a 10-second timeout, but the command can easily take over
a minute to finish, even on reasonable article ranges (< 100), when
the news server is busy.
I'd suggest bumping this up to 500 seconds. Also, I'd increase all the
other 10-second timeouts to 200 seconds: I just don't see the sense in
aborting whenever the news server is a bit sluggish. Waiting 200
seconds for an initial connection does seem rather long though ... I'd
suggest giving the server 100 seconds to produce a "200 NNTP server
ready" message before concluding it's probably down.
A patch is attached below; it applies to version 1.2 of nntp.pl:
$Header: nntp.pl,v 1.2 91/11/12 11:53:36 rkrebs Exp $
Matt
*** nntp.pl.old Wed Sep 16 19:44:52 1992
--- nntp.pl Wed Sep 16 19:45:01 1992
***************
*** 71,77 ****
($conn = &chat'open_port($server, 119)) ||
die sprintf($badservermsg, $server, $!);
! &chat'expect($conn, 30,
"^20[01] .*$cr", '$conn',
"^5.. .*$cr", 'die "Server error: " . $&',
"TIMEOUT", 'die "Server connection timeout: $server\n"');
--- 71,77 ----
($conn = &chat'open_port($server, 119)) ||
die sprintf($badservermsg, $server, $!);
! &chat'expect($conn, 100,
"^20[01] .*$cr", '$conn',
"^5.. .*$cr", 'die "Server error: " . $&',
"TIMEOUT", 'die "Server connection timeout: $server\n"');
***************
*** 121,127 ****
# get a list of all the groups, one line at a time
until ($done)
{
! &chat'expect($conn, 10,
"^215 .*$cr", ';',
"^5.. .*$cr", '$done = 1, warn "$&"',
"^\\.$cr", '$done = 1',
--- 121,127 ----
# get a list of all the groups, one line at a time
until ($done)
{
! &chat'expect($conn, 200,
"^215 .*$cr", ';',
"^5.. .*$cr", '$done = 1, warn "$&"',
"^\\.$cr", '$done = 1',
***************
*** 171,177 ****
defined($groups{$ng}) || return ();
&chat'print($conn, "group $ng\n");
! ($artcls = &chat'expect($conn, 10,
"^211 .*$cr", '$&',
"^4.. .*$cr", '()')) || return ();
(split(/ /, $artcls))[1..3];
--- 171,177 ----
defined($groups{$ng}) || return ();
&chat'print($conn, "group $ng\n");
! ($artcls = &chat'expect($conn, 200,
"^211 .*$cr", '$&',
"^4.. .*$cr", '()')) || return ();
(split(/ /, $artcls))[1..3];
***************
*** 190,196 ****
local(@msg);
&chat'print($conn, "$cmd $num\n");
! $msgok = &chat'expect($conn, 10,
"^220 .*$cr", '1',
"^222 .*$cr", '1',
"^4.. .*$cr", '0');
--- 190,196 ----
local(@msg);
&chat'print($conn, "$cmd $num\n");
! $msgok = &chat'expect($conn, 200,
"^220 .*$cr", '1',
"^222 .*$cr", '1',
"^4.. .*$cr", '0');
***************
*** 200,206 ****
# a dot on a line by itself.
while (! $done)
{
! push(@msg, &chat'expect($conn, 10,
"^\\.$cr", '$done = 1; ()',
".*$cr", '$&',
"TIMEOUT", '$done = 1; ()'));
--- 200,206 ----
# a dot on a line by itself.
while (! $done)
{
! push(@msg, &chat'expect($conn, 200,
"^\\.$cr", '$done = 1; ()',
".*$cr", '$&',
"TIMEOUT", '$done = 1; ()'));
***************
*** 255,261 ****
@flds = ();
&chat'print($conn, "xhdr $flname $num\n");
! &chat'expect($conn, 10,
"^221 .*$cr", '1',
"^4.. .*$cr", '0',
"TIMEOUT", '0') || return($ret);
--- 255,261 ----
@flds = ();
&chat'print($conn, "xhdr $flname $num\n");
! &chat'expect($conn, 200,
"^221 .*$cr", '1',
"^4.. .*$cr", '0',
"TIMEOUT", '0') || return($ret);
***************
*** 262,268 ****
while (! $done)
{
! &chat'expect($conn, 10,
"^\\.$cr", '$done = 1',
"^..*$cr", 'chop($&); chop($&); $ret = $&',
"TIMEOUT", '$done = 1');
--- 262,268 ----
while (! $done)
{
! &chat'expect($conn, 200,
"^\\.$cr", '$done = 1',
"^..*$cr", 'chop($&); chop($&); $ret = $&',
"TIMEOUT", '$done = 1');
***************
*** 283,289 ****
@flds = ();
&chat'print($conn, "xhdr $flname $first-$last\n");
! &chat'expect($conn, 10,
"^221 .*$cr", '1',
"^4.. .*$cr", '0',
"TIMEOUT", '0') || return;
--- 283,289 ----
@flds = ();
&chat'print($conn, "xhdr $flname $first-$last\n");
! &chat'expect($conn, 500,
"^221 .*$cr", '1',
"^4.. .*$cr", '0',
"TIMEOUT", '0') || return;
***************
*** 290,296 ****
while (! $done)
{
! &chat'expect($conn, 10,
"^([0-9]+) .*$cr", '$flds[$1 - $first] = $&',
"^\\.$cr", '$done = 1',
"TIMEOUT", '$done = 1');
--- 290,296 ----
while (! $done)
{
! &chat'expect($conn, 200,
"^([0-9]+) .*$cr", '$flds[$1 - $first] = $&',
"^\\.$cr", '$done = 1',
"TIMEOUT", '$done = 1');