To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.admin.generalOpen lugnet.admin.general in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Administrative / General / 1027
1026  |  1028
Subject: 
Re: posting failure?
Newsgroups: 
lugnet.admin.general
Date: 
Mon, 8 Feb 1999 08:53:41 GMT
Viewed: 
1210 times
  
In lugnet.admin.general, lehman@javanet.com (Todd Lehman) writes:
[...]
Anyway, this is a particularly nasty bugaboo because articles over 16.5 KB
posted from the web interface or the e-mail gateway simply disappear with no
error message!  I suspect that an exception is being raised without proper
handling in the Net::NNTP class or one of its ancestors.
[...]

Getting closer...I have a workaround.  I'll have to talk to the authors of
the Net::Cmd module to be absolutely certain about the nature of the
problem, but I think I see it clearly now.

The post() method of Net::NNTP goes like this[1]:

   sub post
   {
      @_ >= 1 or croak 'usage: $nntp->post( [ MESSAGE ] )';
      my $nntp = shift;

      $nntp->_POST() && $nntp->datasend(@_)
         ? @_ == 0 || $nntp->dataend
         : undef;
   }

And datasend() is defined in the parent class Net::Cmd and goes like
this[1]:

   sub datasend
   {
      my $cmd = shift;
      my $arr = @_ == 1 && ref($_[0]) ? $_[0] : \@_;
      my $line = join("" ,@$arr);

      return 1
         unless length($line);

      if($cmd->debug)
      {
         my $b = "$cmd>>> ";
         print STDERR $b,join("\n$b",split(/\n/,$line)),"\n";
      }

      $line =~ s/\n/\015\012/sgo;

      ${*$cmd}{'net_cmd_lastch'} ||= " ";
      $line = ${*$cmd}{'net_cmd_lastch'} . $line;

      $line =~ s/(\012\.)/$1./sog;

      ${*$cmd}{'net_cmd_lastch'} = substr($line,-1,1);

      my $len = length($line) - 1;

      return $len == 0 ||
         syswrite($cmd, $line, $len, 1) == $len;
   }

I think the bug almost certainly lies in the last line of datasend().  The
Camel Book says that callers of syswrite() should be prepared to handle the
problems that standard I/O normally handles, such as partial writes.[2]

Since ~16KB is a reasonable buffer size for sockets, and will handle most
news articles without insidious problems, I think what's happening is that
datasend() is returning false to post() when it's sent largish chunks of
data.  Note also that post() doesn't call dataend() if datasend() fails.
This seems to cause quit() to hang later.

Instead of using post(@lines), a successful workaround is to use post() and
send the article line-by-line with repeated datasend($line) calls.
(Luckily, calling datasend() directly is a perfectly acceptable use of
Net::NNTP, according to its docs, so it's not really a kludge -- although
it's probably 1/100 second slower on a large article.)

Anyway, I'll go apply the workaround to the mail-gateway and web-interface
posting scripts -- then you can post your 27 KB .DAT file[3] -- and then
I'll probably submit a patch for consideration to the author of Net::Cmd,
which will also give me a chance to become more certain about the true
nature of the bug.

--Todd

[1] The post() and datasend() functions in the versions of Net::NNTP and
Net::Cmd that I have installed are identical to the latest & greatest
releases on CPAN.

[2] _Programming_Perl_, Second Edition, p. 231.

[3] Some of the lines on the KODIAK1.DAT file you uploaded are longer than
80 characters; you probably will experience line-wrapping problems if you
post it through the web interface.  I recommend sending it through the
e-mail gateway to lugnet.cad.dat.  Maybe the news-posting script can be
modified later to specially handle an actual .DAT file-upload...



Message has 2 Replies:
  Re: posting failure?
 
(...) Todd, Thanks for all your hard work to diagnose this problem. I've sent off the file via email again, so we'll see if it works now. Thanks again, Ben. (26 years ago, 10-Feb-99, to lugnet.admin.general)
  Re: posting failure?
 
(...) Well, what I wrote above in February was not entirely correct. It is necessary (at least on this system) to FLUSH the socket's buffer when it becomes full. I am not very knowledgeable about sockets in Perl, and it's not a well-documented area, (...) (26 years ago, 12-Apr-99, to lugnet.admin.general)

Message is in Reply To:
  Re: posting failure?
 
(...) Well, this bug is certainly interesting. (Thank you for discovering this, BTW.) I've got the problem narrowed down to a file size limitation of approximately 16.5 KB in an NNTP connection library. I know that it's not a bug somewhere in the (...) (26 years ago, 8-Feb-99, to lugnet.admin.general)

12 Messages in This Thread:


Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR