aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Net/IMAP/InterIMAP.pm
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2016-03-08 23:13:43 +0100
committerGuilhem Moulin <guilhem@fripost.org>2016-03-08 23:13:43 +0100
commitec87e1965d758bc3af4403a3cf469c3297f8cb1a (patch)
tree64989e2ace4e84da226177cdc9a8e95bd5c2f5ef /lib/Net/IMAP/InterIMAP.pm
parentaecdd0c6657e3edb0482751efffdcafb96f2c2c5 (diff)
parent6bf9ee9a1e1c704490489f682dfe106f2c1ee46a (diff)
Merge branch 'master' into debian
Diffstat (limited to 'lib/Net/IMAP/InterIMAP.pm')
-rw-r--r--lib/Net/IMAP/InterIMAP.pm13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/Net/IMAP/InterIMAP.pm b/lib/Net/IMAP/InterIMAP.pm
index be62a9d..785de38 100644
--- a/lib/Net/IMAP/InterIMAP.pm
+++ b/lib/Net/IMAP/InterIMAP.pm
@@ -1366,15 +1366,18 @@ sub _tcp_connect($$$) {
my ($err, @res) = getaddrinfo($host, $port, \%hints);
$self->fail("Can't getaddrinfo: $err") if $err ne '';
+ SOCKETS:
foreach my $ai (@res) {
- socket my $s, $ai->{family}, $ai->{socktype}, $ai->{protocol};
+ socket (my $s, $ai->{family}, $ai->{socktype}, $ai->{protocol}) or $self->panic("connect: $!");
# TODO: add a connection timeout
# http://devpit.org/wiki/Connect%28%29_with_timeout_%28in_Perl%29
- if (defined $s and connect($s, $ai->{addr})) {
- my $flags = fcntl($s, F_GETFL, 0) or $self->panic("fcntl F_GETFL: $!");
- fcntl($s, F_SETFL, $flags | FD_CLOEXEC) or $self->panic("fcntl F_SETFL: $!");
- return $s;
+ until (connect($s, $ai->{addr})) {
+ next if $! == EINTR; # try again if connect(2) was interrupted by a signal
+ next SOCKETS;
}
+ my $flags = fcntl($s, F_GETFL, 0) or $self->panic("fcntl F_GETFL: $!");
+ fcntl($s, F_SETFL, $flags | FD_CLOEXEC) or $self->panic("fcntl F_SETFL: $!");
+ return $s;
}
$self->fail("Can't connect to $host:$port");
}