> [EMAIL PROTECTED] - Tue Feb 20 00:50:27 2001]:
> 
> 
> -----------------------------------------------------------------
> [Please enter your report here]
> 
> It appears there is a quirk in the behavior of select() with udp
> sockets on some systems (Linux, others?).  Apparently even when
> select() indicates a packet is waiting, subsequent recv() can still
> fail with "Connection refused".  The discussion at
> http://www.uwsg.iu.edu/hypermail/linux/net/9508.0/0017.html
> proves I'm not insane.
> 
> In Net::Ping::ping_udp() this leads to an error when the undefined
> value of $from_saddr is fed into sockaddr_in(): "Bad arg length
> for Socket::unpack_sockaddr_in..."
> 
> The workaround is simple: Just check $from_saddr for defined-ness and
> do
> nothing if it isn't.  The patch below gives the right behavior on my
> Linux
> box, i.e. it times out when udp echo is disallowed and behaves as
> before
> when it's allowed.  I haven't tested anything else.
> 
> Regards, Anno
> 
> 
> --- Ping.pm   Fri Feb 16 13:09:05 2001
> +++ Ping_new.pm       Tue Feb 20 17:46:01 2001
> @@ -366,17 +366,19 @@
>              $ret = undef;
>              $done = 1;
>          }
> -        elsif ($nfound)         # A packet is waiting
> +        elsif ($nfound)         # A packet is probably waiting
>          {
>              $from_msg = "";
>              $from_saddr = recv($self->{"fh"}, $from_msg, 1500,
> $flags);
> -            ($from_port, $from_ip) = sockaddr_in($from_saddr);
> -            if (($from_ip eq $ip) &&        # Does the packet check
> out?
> -                ($from_port == $self->{"port_num"}) &&
> -                ($from_msg eq $msg))
> -            {
> -                $ret = 1;       # It's a winner
> -                $done = 1;
> +            if (defined $from_saddr) { # quirk in select on udp
> socket
> +                ($from_port, $from_ip) = sockaddr_in($from_saddr);
> +                if (($from_ip eq $ip) &&        # Does the packet
> check out?
> +                    ($from_port == $self->{"port_num"}) &&
> +                    ($from_msg eq $msg))
> +                {
> +                    $ret = 1;       # It's a winner
> +                    $done = 1;
> +                }
>              }
>          }
>          else                    # Oops, timed out
> @@ -385,7 +387,7 @@
>          }
>      }
>      return($ret);
> -}
> +}
> 
>  # Description:  Close the connection unless we are using the tcp
>  # protocol, since it will already be closed.
> 

There have been changes to this code that appear to handle your concerns
without implementing your patch.  If this is still a problem, please let
us know.

Reply via email to