I was writing a CGI proxy that strips GET headers and that behaves like an
SSL Tunnelling proxy. It was running. But the webserver was soaking
up error messages, so I sent them to a remote socket. Then the die messages
were still being lost, and using CGI::Carp fixed that, at least in
Windows NT with Activestate Perl 522. But in linux Perl 5.6.0, the
CGI::Carp code flushed bugs in LWPng. LWPng is by Gisle Aas.


The program showing the problem:

./bugs.cgi :
--------------------------------------------------------------------
  1:  #!/usr/bin/perl -w
  2:
  3:  use strict;  # use warnings qw(all);
  4:
  5:  use CGI::Carp qw(fatalsToBrowser);
  6:  CGI::Carp::set_message("Execution ends");
  7:
  8*  use LWP::Conn::HTTP ();
  9:
10:  1;
--------------------------------------------------------------------

LWPng was not installed into the Perl directories. Instead the program
was executed in a directory containing LWP. The version of Perl was
5.6.0 for linux, dated Apr-2000.

The problem occurred at line 613 of './LWP/Conn/HTTP.pm', which is
nearly where Perl's 'base.pm' tried to use a 'require' to find
"LWP::Conn::HTTP::Active", a package immediately above and in the same
text file.


./LWP/Conn/HTTP.pm :
--------------------------------------------------------------------
337
338 package LWP::Conn::HTTP::Active;
339 use base qw(LWP::Conn::HTTP);
340
341 use LWP::MainLoop qw(mainloop);
342
343 sub activate
344 {
345     my $self = shift;
346     $self->new_request;  # try to pipeline another request
347 }
...

611
612  package LWP::Conn::HTTP::ContLen;
613* use base qw(LWP::Conn::HTTP::Active);
614
615  sub check_rbuf
616  {
617      my $self = shift;
618      my $buf      = \ *$self->{'lwp_rbuf'};
619      my $res      =   *$self->{'lwp_res'};
620      my $cont_len =   *$self->{'lwp_cont_len'};
621
622      my $data = substr($$buf, 0, $cont_len);
623      substr($$buf, 0, $cont_len) = '';
624      $cont_len -= length($data);
...
--------------------------------------------------------------------


/usr/local/lib/perl5/5.6.0/base.pm :
--------------------------------------------------------------------
50 sub import {
51     my $class = shift;
52     my $fields_base;
53     my $pkg = caller(0);
54
55     foreach my $base (@_) {
56         next if $pkg->isa($base);
57         push @{"$pkg\::ISA"}, $base;
58         unless (exists ${"$base\::"}{VERSION}) {
59             eval "require $base";
60             # Only ignore "Can't locate" errors from our eval require.
61             # Other fatal errors (syntax etc) must be reported.
62*            die if $@ && $@ !~ /^Can't locate .*? at \(eval /;
63             unless (%{"$base\::"}) {
64                 require Carp;
65                 Carp::croak("Base class package \"$base\" is empty.\n",
--------------------------------------------------------------------

This is the output that by bugs.cgi produced:
(a problem with blocking was partially fixed in this output. There
is another with the require in EventLoop the imports an absent high
resolution timing 'time' function).

In the following, [*$INC*] is the string:
'(@INC contains: /usr/local/lib/perl5/5.6.0/i586-linux
/usr/local/lib/perl5/5.6.0 /usr/local/lib/perl5/site_perl/5.6.0/i586-
linux /usr/local/lib/perl5/site_perl/5.6.0
/usr/local/lib/perl5/site_perl .)'



---------------------------------------------------------------------

06:49:39 ]$ perl -wc bugs.cgi

[Tue Sep  5 06:49:53 2000] Fcntl.pm: Subroutine blocking redefined at
LWP/Conn/_Connect.pm line 43.
Content-type: text/html

<H1>Software error:</H1>
<CODE>Can't locate LWP/Conn/HTTP/Active.pm in @INC [*$INC*] at (eval
9) line 3.
</CODE><P>
For help, please send mail to this site's webmaster, giving this
error message and the time and date of the error.

Content-type: text/html

<H1>Software error:</H1>
<CODE>[Tue Sep  5 06:49:53 2000] Active.pm: Can't locate
LWP/Conn/HTTP/Active.pm in @INC [*$INC*] at (eval 9) line 3.
         ...propagated at /usr/local/lib/perl5/5.6.0/base.pm line 62.
</CODE><P>
For help, please send mail to this site's webmaster, giving this
error message and the time and date of the error.

Content-type: text/html
...


Content-type: text/html

<H1>Software error:</H1>
<CODE>[Tue Sep  5 06:49:53 2000] HTTP.pm: [Tue Sep  5 06:49:53 2000]
HTTP.pm: [Tue Sep  5 06:49:53 2000] HTTP.pm: [Tue Sep  5 06:49:53
2000] Active.pm: Can't locate LWP/Conn/HTTP/Active.pm in @INC
[*$INC*] at (eval 9) line 3.
[Tue Sep  5 06:49:53 2000] HTTP.pm: [Tue Sep  5 06:49:53 2000]
HTTP.pm: [Tue Sep  5 06:49:53 2000] HTTP.pm:     ...propagated at
/usr/local/lib/perl5/5.6.0/base.pm line 62.
[Tue Sep  5 06:49:53 2000] HTTP.pm: [Tue Sep  5 06:49:53 2000]
HTTP.pm: BEGIN failed--compilation aborted at LWP/Conn/HTTP.pm line
613.
[Tue Sep  5 06:49:53 2000] HTTP.pm: Compilation failed in require at
LWP/Conn/HTTP.pm line 8.
BEGIN failed--compilation aborted at bugs.cgi line 8.
</CODE><P>
For help, please send mail to this site's webmaster, giving this
error message and the time and date of the error.

[Tue Sep  5 06:49:53 2000] bugs.cgi: [Tue Sep  5 06:49:53 2000]
HTTP.pm: [Tue Sep  5 06:49:53 2000] HTTP.pm: [Tue Sep  5 06:49:53
2000] HTTP.pm: [Tue Sep  5 06:49:53 2000] Active.pm: Can't locate
LWP/Conn/HTTP/Active.pm in @INC [*$INC*] at (eval 9) line 3.
[Tue Sep  5 06:49:53 2000] bugs.cgi: [Tue Sep  5 06:49:53 2000]
HTTP.pm: [Tue Sep  5 06:49:53 2000] HTTP.pm: [Tue Sep  5 06:49:53
2000] HTTP.pm:         ...propagated at
/usr/local/lib/perl5/5.6.0/base.pm line 62.
[Tue Sep  5 06:49:53 2000] bugs.cgi: [Tue Sep  5 06:49:53 2000]
HTTP.pm: [Tue Sep  5 06:49:53 2000] HTTP.pm: BEGIN failed--
compilation aborted at LWP/Conn/HTTP.pm line 613.
[Tue Sep  5 06:49:53 2000] bugs.cgi: [Tue Sep  5 06:49:53 2000]
HTTP.pm: Compilation failed in require at LWP/Conn/HTTP.pm line 8.
[Tue Sep  5 06:49:53 2000] bugs.cgi: BEGIN failed--compilation
aborted at bugs.cgi line 8.

06:49:53 ]$

---------------------------------------------------------------------

Is Perl going to be rewritten so that its package features are more
simple, and day, more like Ada 95?. It seems to be an overly
difficult part of Perl to learn about. Improved error messages could
assist but I doubt that that is a fix that is needed. A better
designed Perl might be preferred by many that don't like to learn
by trial and error or by using a debugger, to see if there is one
way to get the program to run.

Non-blocking gethostbyname:

Net:DNS doesn't run in both Windows 95 and Windows NT, in Activestate
533 and 5.6.0. Usenet messages say it used to run in Windows, so maybe
it is a Perl bug.

What is happening on putting into Perl, a non-blocking gethostbyname
feature?.  LWPng much needs it. Blocking DNS lookups would slow down
any variant HTTP/1.1 tunnelling SSL Tunnelling-ish proxy.
Net::DNS may be moving in a direction (if moving at all) of reading
the registry and some linux/unix files to find out what the IP number
of the DNS server is. Instead of Perl code that may not always run,
assembling UDP packets and reading files at different locations in
unknown machines, couldn't Perl's developers just provide a
non-blocking 'gethostbyname' to do lookups?. Is it a hidden feature
of Perl already?.

Is there any plan to get non-blocking DNS lookups for LWPng?.

(Early version proxy code at http://www.ijs.co.nz/code/sorm**.zip)







E-mail: Craig Carey <[EMAIL PROTECTED]>  (backup [EMAIL PROTECTED])
Auckland, NZ. |  Snooz Metasearch: http://www.ijs.co.nz/info/snooz.htm


Reply via email to