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 543537f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 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
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 543537f

Please sign in to comment.