aboutsummaryrefslogtreecommitdiffstats
path: root/ext
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-04-20 02:11:10 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-04-20 02:11:10 +0000
commitb88296be43b7fe0c0a3b477dae04aa26ee71128e (patch)
treed47ee804618835c70185fe3a54e5dc2cfa93e175 /ext
parent038c0e5a804f1736e884f6741b9d7e84606580d7 (diff)
downloadruby-b88296be43b7fe0c0a3b477dae04aa26ee71128e.tar.gz
connect_nonblock(..., exception: false) does not raise EISCONN
* ext/socket/socket.c (sock_connect_nonblock): do not raise EISCONN [ruby-core:68926] [Feature #11072] * test/socket/test_nonblock.rb: check non-EISCONN on 2nd connect This is to reduce exceptions for code which issues a (IMHO, unnecessary) second connect() syscall. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50347 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/socket/socket.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index a514b9ab09..bb23703706 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -509,6 +509,12 @@ sock_connect_nonblock(int argc, VALUE *argv, VALUE sock)
}
rb_readwrite_sys_fail(RB_IO_WAIT_WRITABLE, "connect(2) would block");
}
+ if (errno == EISCONN) {
+ if (!NIL_P(opts) &&
+ Qfalse == rb_hash_lookup2(opts, sym_exception, Qundef)) {
+ return INT2FIX(0);
+ }
+ }
rsock_sys_fail_raddrinfo_or_sockaddr("connect(2)", addr, rai);
}