Skip to content

Commit

Permalink
send errors are now handled and returned
Browse files Browse the repository at this point in the history
as failed Futures for ping sockets and warnings for the shared raw socket
because IO::Async::Socket->send has no api for returning failures, see RT#97943

this can happen if you e.g. try to ping an IPv6 address without having a route
  • Loading branch information
abraxxa committed Jan 23, 2018
1 parent 6cf592c commit 3604bc4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Revision history for {{$dist->name}}
dispatching for increased performance (O vs. O^2)
- don't use Net::Frame::Simple for ICMP and ICMPv6 reply packet parsing for
improved performance
- send errors are now handled and returned
as failed Futures for ping sockets and warnings for the shared raw socket

0.003003 2018-01-17 17:03:08+01:00 Europe/Vienna
- fix parsing of ICMP responses when using raw socket
Expand Down
2 changes: 1 addition & 1 deletion dist.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ author = Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
author = Alexander Hartmaier <abraxxa@cpan.org>
license = Perl_5
copyright_holder = Arthur Axel "fREW" Schmidt, Alexander Hartmaier
version = 0.003003
version = 0.003903

[NextRelease]
[@Git]
Expand Down
12 changes: 10 additions & 2 deletions lib/Net/Async/Ping/ICMP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,13 @@ sub _build__raw_socket {

my $socket = IO::Async::Socket->new(
handle => $fh,
on_send_error => sub {
my ( $self, $errno ) = @_;
warn "Send error: $errno\n";
},
on_recv_error => sub {
my ( $self, $errno ) = @_;
warn "Receive error: $errno";
warn "Receive error: $errno\n";
},
on_recv => $on_recv,
);
Expand Down Expand Up @@ -259,9 +263,13 @@ sub ping {

$socket = IO::Async::Socket->new(
handle => $ping_fh,
on_send_error => sub {
my ( $self, $errno ) = @_;
$f->fail("Send error: $errno");
},
on_recv_error => sub {
my ( $self, $errno ) = @_;
$f->fail('Receive error');
$f->fail("Receive error: $errno");
},
on_recv => $on_recv,
);
Expand Down
12 changes: 10 additions & 2 deletions lib/Net/Async/Ping/ICMPv6.pm
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,13 @@ sub _build__raw_socket {

my $socket = IO::Async::Socket->new(
handle => $fh,
on_send_error => sub {
my ( $self, $errno ) = @_;
warn "Send error: $errno\n";
},
on_recv_error => sub {
my ( $self, $errno ) = @_;
warn "Receive error: $errno";
warn "Receive error: $errno\n";
},
on_recv => $on_recv,
);
Expand Down Expand Up @@ -265,9 +269,13 @@ sub ping {

$socket = IO::Async::Socket->new(
handle => $ping_fh,
on_send_error => sub {
my ( $self, $errno ) = @_;
$f->fail("Send error: $errno");
},
on_recv_error => sub {
my ( $self, $errno ) = @_;
$f->fail('Receive error');
$f->fail("Receive error: $errno");
},
on_recv => $on_recv,
);
Expand Down

0 comments on commit 3604bc4

Please sign in to comment.