summaryrefslogtreecommitdiff
path: root/ext/socket/socket.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-23 08:57:48 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-23 08:57:48 +0000
commitf4166e2dd7a4d9be95f160e19303ddeeb5d27ab4 (patch)
tree54a609327994753d5579a07797f199fff86c3dc4 /ext/socket/socket.c
parentd15f30882ae8cd6acd27fed5cbb046b5c7c15549 (diff)
prefer rb_syserr_fail
* file.c, io.c, util.c: prefer rb_syserr_fail with saved errno over setting errno then call rb_sys_fail, not to be clobbered potentially and to reduce thread local errno accesses. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53264 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/socket.c')
-rw-r--r--ext/socket/socket.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 0514bb6..d71a94a 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -452,18 +452,19 @@ sock_connect_nonblock(VALUE sock, VALUE addr, VALUE ex)
rb_io_set_nonblock(fptr);
n = connect(fptr->fd, (struct sockaddr*)RSTRING_PTR(addr), RSTRING_SOCKLEN(addr));
if (n < 0) {
- if (errno == EINPROGRESS) {
+ int e = errno;
+ if (e == EINPROGRESS) {
if (ex == Qfalse) {
return sym_wait_writable;
}
rb_readwrite_sys_fail(RB_IO_WAIT_WRITABLE, "connect(2) would block");
}
- if (errno == EISCONN) {
+ if (e == EISCONN) {
if (ex == Qfalse) {
return INT2FIX(0);
}
}
- rsock_sys_fail_raddrinfo_or_sockaddr("connect(2)", addr, rai);
+ rsock_syserr_fail_raddrinfo_or_sockaddr(e, "connect(2)", addr, rai);
}
return INT2FIX(n);