develooper Front page | perl.libwww | Postings from September 2001

Re: LWP::ConnCache Question

From:
Gisle Aas
Date:
September 7, 2001 12:11
Subject:
Re: LWP::ConnCache Question
Message ID:
lrpu92ddg1.fsf@caliper.ActiveState.com
Roger Wegmann <wegmann@eurospider.com> writes:

> When I use the protocol LWP::Protocol::http11 with activated LWP::ConnCache, 
> the connections are not closed automatically, even when the connection limit 
> is reached? Is that right? Do I have to subclassing LWP::ConnCache and 
> implement the sub dropping() that closes the connection?

The connections where supposed to close by themselves.  These is a bug
in the current LWP::Protocol::http11 module that made all sockets stay
around forever.  The reason is that they all made this private
IO::Select object pointing back to themselves.  That's a circular
reference and the refcount would never drop to zero.

This patch is just a temporary fix as it will slow down things a bit.
I will probably just do the select stuff directly in the end.

Regards,
Gisle



Index: lib/LWP/Protocol/http11.pm
===================================================================
RCS file: /cvsroot/libwww-perl/lwp5/lib/LWP/Protocol/http11.pm,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -p -u -r1.22 -r1.23
--- lib/LWP/Protocol/http11.pm	2001/08/28 04:34:31	1.22
+++ lib/LWP/Protocol/http11.pm	2001/09/07 19:04:16	1.23
@@ -1,4 +1,4 @@
-# $Id: http11.pm,v 1.22 2001/08/28 04:34:31 gisle Exp $
+# $Id: http11.pm,v 1.23 2001/09/07 19:04:16 gisle Exp $
 #
 # You can tell LWP to use this module for 'http' requests by running
 # code like this before you make requests:
@@ -30,7 +30,7 @@ my $CRLF = "\015\012";
     sub sysread {
 	my $self = shift;
 	if (my $timeout = ${*$self}{io_socket_timeout}) {
-	    my $io_sel = (${*$self}{myhttp_io_sel} ||= $self->io_sel);
+	    my $io_sel = $self->io_sel;
 	    die "read timeout" unless $io_sel->can_read($timeout);
 	}
 	sysread($self, $_[0], $_[1], $_[2] || 0);
@@ -38,12 +38,8 @@ my $CRLF = "\015\012";
 
     sub io_sel {
 	my $self = shift;
-	my $io_sel = (${*$self}{myhttp_io_sel} ||=
-		      do {
-			  require IO::Select;
-			  IO::Select->new($self);
-		      });
-	return $io_sel;
+	require IO::Select;
+	return IO::Select->new($self);
     }
 
     sub ping {



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About