[Fwd: LWP::Simple::get() and 5.004_01 debugger shoot each other in the foot]

John Chambers (jmc@nexen.com)
Wed, 16 Jul 1997 09:49:49 -0400


This is a multi-part message in MIME format.

--------------4487EB716201DD5652BFA1D7
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I posted this, and then found the comments that I thought I'd seen
about there being a mailing list.  So if the netscape mailer works
right, this will send a copy to  the mailing list ...


-- 
echo 'Reply-To: John Chambers <jc@eddie.mit.edu>'
saying $(HOME)/JAPH
# Dumb mailer doesn't grok execable .signature files. ;-)

--------------4487EB716201DD5652BFA1D7
Content-Type: message/news
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Path: nexen.nexen.com!usenet
From: John Chambers <jmc@nexen.com>
Newsgroups: comp.lang.perl.modules
Subject: LWP::Simple::get() and 5.004_01 debugger shoot each other in the foot
Date: Tue, 15 Jul 1997 14:55:24 -0400
Organization: Ascom Nexion
Message-ID: <33CBC79C.41C67EA6@nexen.com>
NNTP-Posting-Host: honk.nexen.com
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 3.02 (X11; I; SunOS 4.1.4 sun4m)

This one took a looooong time to diagnose, because naturally I tried
looking at it with -dw, and it only fails when the debugger is running.
What I've been trying to do is learn to use LWP::Simple, and the get()
routine was showing flakiness, sometimes reading URLs just find, other
times returning the contents of one URL and then failing for others.

It turns out that if you 1) are running the debugger, and 2) ask get()
to get a directory, it succeeds just once, and from then on always
fails.  If the URL is to a file (including an index.html), then things
work ok.  If you don't use perl's -d option, things also work ok.  But
there's something in what servers return for directories that somehow
interacts with the debugger, and screws up subsequent calls of get().

Here's my distilled test, accepts URLs and gets each one 3 times.  If
you point it at a directory that doesn't contain index.html, it will
succeed the first time and fail the other two times.  At least, with
perl 5.004_01 on SunOS 4.1.2, that's what happens.


use LWP::Simple;
$| = 1; $N = 3;
for $url (@ARGV) {
    print "Load file \"$url\"\n";
    for ($i = 1; $i <= $N; $i++) {
        $try[$i] = LWP::Simple::get($url);
        if ($try[$i]) {
            print "Try $i got ", length($try[$i]), " bytes.\n";
            if (open(O,">w3test.out$i")) {
                print O $try[$i];
                close O;
            }
        } else {
            print "Try $i failed ($!).\n"
        }
    }
}
exit 0;


Anyone have any idea how to run this down and fix it?  Or is there
maybe some way to "reset" LWP::Simple so that whatever is hosed gets
wiped out, and each get() is "from scratch"?

BTW, the value of $! is always "Bad file number", but that's its
value even for successes, so it's probably meaningless.

Another curiosity is that get() seems to really mess up the debugger.
If you set a breakpoint at the get() call, and use 'n' to do the call,
you don't get control back at the next line.  And the next line seems
not to ever run.  What seems to happen is that when get() returns, it
forces a return from the function that calls it, too, returning to
some higher-level routine.  It's as if get() has messed up the call
stack, and popped off one or more functions in addition to itself.

-- 
echo 'Reply-To: John Chambers <jc@eddie.mit.edu>'
saying $(HOME)/JAPH
# Dumb mailer doesn't grok execable .signature files. ;-)

--------------4487EB716201DD5652BFA1D7--