diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 2003-05-17 06:07:07 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 2003-05-17 06:07:07 +0000 |
commit | 6dbac12b81c0a4e61d1a9c7a1f12e0ee3256cdda (patch) | |
tree | 7778c495547140113436857b929442f06dfd68d6 /lib | |
parent | eb194dd9b37694f4482689d052c0bd96e472200f (diff) | |
download | perl-6dbac12b81c0a4e61d1a9c7a1f12e0ee3256cdda.tar.gz |
apply Net::Ping patch that makes the fork()-based approach
work better on windows (Marcus Holland-Moritz <mhx-perl@gmx.net>)
the code this affects is currently not enabled anywhere, but
could be enabled if the non-blocking approach runs into problems
on older windows versions
p4raw-id: //depot/perl@19536
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Net/Ping.pm | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/Net/Ping.pm b/lib/Net/Ping.pm index f50967cd94..05a3fd5ce1 100644 --- a/lib/Net/Ping.pm +++ b/lib/Net/Ping.pm @@ -565,7 +565,9 @@ sub tcp_connect }; my $do_connect = sub { $self->{"ip"} = $ip; - return ($ret = connect($self->{"fh"}, $saddr)); + # ECONNREFUSED is 10061 on MSWin32. If we pass it as child error through $?, + # we'll get (10061 & 255) = 77, so we cannot check it in the parent process. + return ($ret = connect($self->{"fh"}, $saddr) || ($! == ECONNREFUSED && !$self->{"econnrefused"})); }; my $do_connect_nb = sub { # Set O_NONBLOCK property on filehandle @@ -667,7 +669,8 @@ sub tcp_connect exit 0; } else { # Pass the error status to the parent - exit $!; + # Make sure that $! <= 255 + exit($! <= 255 ? $! : 255); } } @@ -692,6 +695,8 @@ sub tcp_connect # within the timeout &{ $do_connect }(); } + # $ret cannot be set by the child process + $ret = !$child_errno; } else { # Time must have run out. # Put that choking client out of its misery |