ruby-changes:38323
From: nobu <ko1@a...>
Date: Thu, 30 Apr 2015 16:39:52 +0900 (JST)
Subject: [ruby-changes:38323] nobu:r50404 (trunk): ipsocket.c: sys_error
nobu 2015-04-30 16:39:46 +0900 (Thu, 30 Apr 2015) New Revision: 50404 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50404 Log: ipsocket.c: sys_error * ext/socket/ipsocket.c (init_inetsock_internal): preserve errno before other library calls and use rb_syserr_fail. [ruby-core:68531] [Bug #10975] Modified files: trunk/ChangeLog trunk/ext/socket/ipsocket.c Index: ChangeLog =================================================================== --- ChangeLog (revision 50403) +++ ChangeLog (revision 50404) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Apr 30 16:39:44 2015 Nobuyoshi Nakada <nobu@r...> + + * ext/socket/ipsocket.c (init_inetsock_internal): preserve errno + before other library calls and use rb_syserr_fail. + [ruby-core:68531] [Bug #10975] + Thu Apr 30 16:22:16 2015 Nobuyoshi Nakada <nobu@r...> * parse.y (lambda): push and reset cmdarg_stack in lambda body. Index: ext/socket/ipsocket.c =================================================================== --- ext/socket/ipsocket.c (revision 50403) +++ ext/socket/ipsocket.c (revision 50404) @@ -41,6 +41,7 @@ inetsock_cleanup(struct inetsock_arg *ar https://github.com/ruby/ruby/blob/trunk/ext/socket/ipsocket.c#L41 static VALUE init_inetsock_internal(struct inetsock_arg *arg) { + int error = 0; int type = arg->type; struct addrinfo *res, *lres; int fd, status = 0, local = 0; @@ -80,6 +81,7 @@ init_inetsock_internal(struct inetsock_a https://github.com/ruby/ruby/blob/trunk/ext/socket/ipsocket.c#L81 syscall = "socket(2)"; fd = status; if (fd < 0) { + error = errno; continue; } arg->fd = fd; @@ -107,6 +109,7 @@ init_inetsock_internal(struct inetsock_a https://github.com/ruby/ruby/blob/trunk/ext/socket/ipsocket.c#L109 } if (status < 0) { + error = errno; close(fd); arg->fd = fd = -1; continue; @@ -124,7 +127,7 @@ init_inetsock_internal(struct inetsock_a https://github.com/ruby/ruby/blob/trunk/ext/socket/ipsocket.c#L127 port = arg->remote.serv; } - rsock_sys_fail_host_port(syscall, host, port); + rsock_syserr_fail_host_port(error, mesg, host, port); } arg->fd = -1; @@ -132,8 +135,9 @@ init_inetsock_internal(struct inetsock_a https://github.com/ruby/ruby/blob/trunk/ext/socket/ipsocket.c#L135 if (type == INET_SERVER) { status = listen(fd, SOMAXCONN); if (status < 0) { + error = errno; close(fd); - rb_sys_fail("listen(2)"); + rb_syserr_fail(error, "listen(2)"); } } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/