Jeff Cours <[EMAIL PROTECTED]> writes:

> Apologies for sending a patch against an older version, but, due to some
> reasons too complicated to go into, I can't currently use cutting-edge
> code. This patch makes timeouts optional. Under Perl 5.00503, I was
> getting an error because that version of Perl doesn't support socket
> timeouts. This patch modifies LWP::Protocol::http::_new_socket() so that
> it doesn't try to set the socket's Timeout option if the timeout value
> is 0 or undefined.

>From what I can see IO::Socket in perl 5.00503 should not make a
difference between passing Timeout => 0 and not passing this argument
at all.  Could you explain what kind of errors you see?

> thanks,
> Jeffdiff -Naur lib/LWP/Protocol/http.pm lib.new/LWP/Protocol/http.pm
> --- lib/LWP/Protocol/http.pm  Wed May 24 09:41:13 2000
> +++ lib.new/LWP/Protocol/http.pm      Thu Sep 13 20:57:48 2001
> @@ -25,12 +25,22 @@
>      my($self, $host, $port, $timeout) = @_;
>  
>      local($^W) = 0;  # IO::Socket::INET can be noisy
> -    my $sock = IO::Socket::INET->new(PeerAddr => $host,
> -                                  PeerPort => $port,
> -                                  Proto    => 'tcp',
> -                                  Timeout  => $timeout,
> -                                  $self->_extra_sock_opts($host, $port),
> -                                 );
> +    my $sock;
> +    if ((defined $timeout) && ($timeout > 0)) {
> +        $sock = IO::Socket::INET->new(PeerAddr => $host,
> +                                   PeerPort => $port,
> +                                   Proto    => 'tcp',
> +                                   Timeout  => $timeout,
> +                                   $self->_extra_sock_opts($host, $port),
> +                                   );
> +    }
> +    else {
> +        $sock = IO::Socket::INET->new(PeerAddr => $host,
> +                                   PeerPort => $port,
> +                                   Proto    => 'tcp',
> +                                   $self->_extra_sock_opts($host, $port),
> +                                   );
> +    }

An easier patch with the same effect might be:

 -                                   Timeout  => $timeout,
 +                                   $timeout ? (Timeout => $timeout) : (),

Regards,
Gisle

Reply via email to