[libanyevent-handle-udp-perl] 47/60: Handle address reuse better
Jonas Smedegaard
js at alioth.debian.org
Mon Sep 30 10:05:45 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 22b1862f1766d3e81e46a510110d92933f9a49b5
Author: Leon Timmermans <fawaka at gmail.com>
Date: Sat Aug 31 14:49:18 2013 +0200
Handle address reuse better
---
Changes | 1 +
lib/AnyEvent/Handle/UDP.pm | 9 +++++++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/Changes b/Changes
index aadea16..965205a 100644
--- a/Changes
+++ b/Changes
@@ -1,6 +1,7 @@
Revision history for AnyEvent-Handle-UDP
{{$NEXT}}
+ Handle address reuse better
0.040 2013-08-29 13:04:30 Europe/Amsterdam
Fix error handling in a number of places
diff --git a/lib/AnyEvent/Handle/UDP.pm b/lib/AnyEvent/Handle/UDP.pm
index c617458..9699a12 100644
--- a/lib/AnyEvent/Handle/UDP.pm
+++ b/lib/AnyEvent/Handle/UDP.pm
@@ -36,11 +36,16 @@ has _connect_addr => (
predicate => '_has_connect_addr',
);
+has reuse_addr => (
+ is => 'ro',
+ default => 1,
+);
+
sub _build_fh {
my $self = shift;
my $ret = bless gensym(), 'IO::Socket';
- $self->_connect_to($ret, $self->_connect_addr) if $self->_has_connect_addr;
$self->_bind_to($ret, $self->_bind_addr) if $self->_has_bind_addr;
+ $self->_connect_to($ret, $self->_connect_addr) if $self->_has_connect_addr;
return $ret;
}
@@ -209,9 +214,9 @@ sub _bind_to {
if (!openhandle($fh)) {
socket $fh, $domain, $type, $proto or redo;
fh_nonblocking $fh, 1;
+ setsockopt $fh, SOL_SOCKET, SO_REUSEADDR, 0+$self->reuse_addr or $self->_error(1, "Couldn't set so_reuseaddr: $!");
}
bind $fh, $sockaddr or $self->_error(1, "Could not bind: $!");
- setsockopt $fh, SOL_SOCKET, SO_REUSEADDR, 1 or $self->_error(1, "Couldn't set so_reuseaddr: $!");
};
if (ref $addr) {
my ($host, $port) = @{$addr};
--
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