[Catalyst] Testserver dies under IE - patch

Jesper Krogh jesper at krogh.cc
Tue Oct 3 11:51:51 CEST 2006


Hi all.

This is a small patch that makes the testserver survive Internet Explorer..

This is probably not the correct fix.. since that would be to find out
what the problem is.. Somehow it seems that the socket dissapears earlier
when IE it in the other end.

patch
--- /usr/share/perl5/Catalyst/Engine/HTTP.pm    2006-07-19
23:45:16.000000000 +0200
+++ lib/Catalyst/Engine/HTTP.pm 2006-10-03 11:43:42.000000000 +0200
@@ -305,13 +305,14 @@
     my ( $self, $handle ) = @_;

     my $remote_sockaddr = getpeername($handle);
-    my ( undef, $iaddr ) = sockaddr_in($remote_sockaddr);
+    my $iaddr;
+   ( undef, $iaddr ) = sockaddr_in($remote_sockaddr) if $remote_sockaddr;
     my $local_sockaddr = getsockname($handle);
     my ( undef, $localiaddr ) = sockaddr_in($local_sockaddr);

     my $data = {
-        peername => gethostbyaddr( $iaddr, AF_INET ) || "localhost",
-        peeraddr => inet_ntoa($iaddr) || "127.0.0.1",
+        peername => $iaddr ? gethostbyaddr( $iaddr, AF_INET ) ||
"localhost/Uknown",
+        peeraddr => $iaddr ? inet_ntoa($iaddr) : "127.0.0.1/Unknown",
         localname => gethostbyaddr( $localiaddr, AF_INET ) || "localhost",
         localaddr => inet_ntoa($localiaddr) || "127.0.0.1",
     };


Stacktrace:
Use of uninitialized value in subroutine entry
        at Socket::sockaddr_in(/usr/lib/perl/5.8/Socket.pm:198)
        at
Catalyst::Engine::HTTP::_socket_data(/usr/share/perl5/Catalyst/Engine/HTTP.pm:308)
        at
Catalyst::Engine::HTTP::_handler(/usr/share/perl5/Catalyst/Engine/HTTP.pm:220)
        at
Catalyst::Engine::HTTP::run(/usr/share/perl5/Catalyst/Engine/HTTP.pm:172)
        at Catalyst::run(/usr/share/perl5/Catalyst.pm:1754)
        at main::(./script/nzdb_server.pl:54)
Bad arg length for Socket::unpack_sockaddr_in, length is 0, should be 16
        at Socket::sockaddr_in(/usr/lib/perl/5.8/Socket.pm:198)
        at
Catalyst::Engine::HTTP::_socket_data(/usr/share/perl5/Catalyst/Engine/HTTP.pm:308)
        at
Catalyst::Engine::HTTP::_handler(/usr/share/perl5/Catalyst/Engine/HTTP.pm:220)
        at
Catalyst::Engine::HTTP::run(/usr/share/perl5/Catalyst/Engine/HTTP.pm:172)
        at Catalyst::run(/usr/share/perl5/Catalyst.pm:1754)
        at main::(./script/nzdb_server.pl:54)

-- 
Jesper Krogh




More information about the Catalyst mailing list