[libanyevent-handle-udp-perl] 13/60: Handle errors better
Jonas Smedegaard
js at alioth.debian.org
Mon Sep 30 10:05:38 UTC 2013
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository libanyevent-handle-udp-perl.
commit 879df56220133a341725b1aeae08ef6e05c1e920
Author: Leon Timmermans <fawaka at gmail.com>
Date: Sun Feb 19 16:59:28 2012 +0100
Handle errors better
---
lib/AnyEvent/Handle/UDP.pm | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/lib/AnyEvent/Handle/UDP.pm b/lib/AnyEvent/Handle/UDP.pm
index c7809d9..b68540d 100644
--- a/lib/AnyEvent/Handle/UDP.pm
+++ b/lib/AnyEvent/Handle/UDP.pm
@@ -10,7 +10,7 @@ use AnyEvent::Socket qw//;
use Carp qw/croak/;
use Const::Fast qw/const/;
-use Errno qw/EAGAIN EWOULDBLOCK/;
+use Errno qw/EAGAIN EWOULDBLOCK EINTR/;
use Scalar::Util qw/reftype looks_like_number/;
use Socket qw/SOL_SOCKET SO_REUSEADDR SOCK_DGRAM/;
use Symbol qw/gensym/;
@@ -166,12 +166,14 @@ sub _error {
return;
}
+my %non_fatal = map { ( $_ => 1 ) } EAGAIN, EWOULDBLOCK, EINTR;
+
sub push_send {
my ($self, $message, $to, $cv) = @_;
$cv ||= defined wantarray ? AnyEvent::CondVar->new : undef;
if (!$self->{writer}) {
my $ret = $self->_send($message, $to, $cv);
- $self->_push_writer($message, $to, $cv) if not defined $ret and ($! == EAGAIN or $! == EWOULDBLOCK);
+ $self->_push_writer($message, $to, $cv) if not defined $ret and $non_fatal{$! + 0};
$self->_drained if $ret;
}
else {
@@ -183,7 +185,7 @@ sub push_send {
sub _send {
my ($self, $message, $to, $cv) = @_;
my $ret = defined $to ? send $self->{fh}, $message, 0, $to : send $self->{fh}, $message, 0;
- $self->on_error->($self->{fh}, 1, "$!") if not defined $ret and ($! != EAGAIN and $! != EWOULDBLOCK);
+ $self->on_error->($self->{fh}, 1, "$!") if not defined $ret and !$non_fatal{$! + 0};
$cv->($ret) if defined $cv and defined $ret;
return $ret;
}
@@ -197,7 +199,7 @@ sub _push_writer {
my $ret = $self->_send(@{$msg}, $to, $cv);
if (not defined $ret) {
unshift @{$self->{buffers}}, $msg;
- $self->on_error->($self->{fh}, 1, "$!") if $! != EAGAIN and $! != EWOULDBLOCK;
+ $self->on_error->($self->{fh}, 1, "$!") if !$non_fatal{$! + 0};
last;
}
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libanyevent-handle-udp-perl.git
More information about the Pkg-perl-cvs-commits
mailing list