ruby-changes:32763
From: naruse <ko1@a...>
Date: Wed, 5 Feb 2014 22:08:38 +0900 (JST)
Subject: [ruby-changes:32763] naruse:r44842 (ruby_2_1): merge revision(s) 44490, 44496: [Backport #9352]
naruse 2014-02-05 22:08:32 +0900 (Wed, 05 Feb 2014) New Revision: 44842 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44842 Log: merge revision(s) 44490,44496: [Backport #9352] * ext/socket/socket.c (rsock_sys_fail_host_port): save and restore errno before calling rb_sys_fail_str to prevent [BUG] errno == 0. Patch by Eric Wong. [ruby-core:59498] [Bug #9352] * ext/socket/socket.c (rsock_sys_fail_path): ditto * ext/socket/socket.c (rsock_sys_fail_sockaddr): ditto * ext/socket/socket.c (rsock_sys_fail_raddrinfo): ditto * ext/socket/socket.c (rsock_sys_fail_raddrinfo_or_sockaddr): ditto * ext/socket/socket.c (rsock_syserr_fail_host_port): add errno argument version anduse rb_syserr_fail_str() instead of rb_sys_fail_str() with restoring errno. * ext/socket/socket.c (rsock_syserr_fail_path): ditto, and rb_syserr_fail(). * ext/socket/socket.c (rsock_sys_fail_sockaddr): ditto, use rsock_syserr_fail_raddrinfo(). * ext/socket/socket.c (rsock_sys_fail_raddrinfo): ditto. * ext/socket/socket.c (setup_domain_and_type): ditto. Modified directories: branches/ruby_2_1/ Modified files: branches/ruby_2_1/ChangeLog branches/ruby_2_1/ext/socket/rubysocket.h branches/ruby_2_1/ext/socket/socket.c branches/ruby_2_1/version.h Index: ruby_2_1/ChangeLog =================================================================== --- ruby_2_1/ChangeLog (revision 44841) +++ ruby_2_1/ChangeLog (revision 44842) @@ -1,3 +1,30 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1 +Wed Feb 5 21:57:40 2014 Nobuyoshi Nakada <nobu@r...> + + * ext/socket/socket.c (rsock_syserr_fail_host_port): add errno + argument version anduse rb_syserr_fail_str() instead of + rb_sys_fail_str() with restoring errno. + + * ext/socket/socket.c (rsock_syserr_fail_path): ditto, and + rb_syserr_fail(). + + * ext/socket/socket.c (rsock_sys_fail_sockaddr): ditto, use + rsock_syserr_fail_raddrinfo(). + + * ext/socket/socket.c (rsock_sys_fail_raddrinfo): ditto. + + * ext/socket/socket.c (setup_domain_and_type): ditto. + +Wed Feb 5 21:57:40 2014 Eric Wong <normalperson@y...> + + * ext/socket/socket.c (rsock_sys_fail_host_port): save and restore errno + before calling rb_sys_fail_str to prevent [BUG] errno == 0. + Patch by Eric Wong. [ruby-core:59498] [Bug #9352] + + * ext/socket/socket.c (rsock_sys_fail_path): ditto + * ext/socket/socket.c (rsock_sys_fail_sockaddr): ditto + * ext/socket/socket.c (rsock_sys_fail_raddrinfo): ditto + * ext/socket/socket.c (rsock_sys_fail_raddrinfo_or_sockaddr): ditto + Wed Feb 5 21:12:02 2014 Nobuyoshi Nakada <nobu@r...> * lib/timeout.rb (Timeout::ExitException.catch): pass arguments Index: ruby_2_1/ext/socket/rubysocket.h =================================================================== --- ruby_2_1/ext/socket/rubysocket.h (revision 44841) +++ ruby_2_1/ext/socket/rubysocket.h (revision 44842) @@ -374,6 +374,12 @@ void rsock_init_sockopt(void); https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ext/socket/rubysocket.h#L374 void rsock_init_sockifaddr(void); void rsock_init_socket_init(void); +NORETURN(void rsock_syserr_fail_host_port(int err, const char *, VALUE, VALUE)); +NORETURN(void rsock_syserr_fail_path(int err, const char *, VALUE)); +NORETURN(void rsock_syserr_fail_sockaddr(int err, const char *mesg, struct sockaddr *addr, socklen_t len)); +NORETURN(void rsock_syserr_fail_raddrinfo(int err, const char *mesg, VALUE rai)); +NORETURN(void rsock_syserr_fail_raddrinfo_or_sockaddr(int err, const char *mesg, VALUE addr, VALUE rai)); + NORETURN(void rsock_sys_fail_host_port(const char *, VALUE, VALUE)); NORETURN(void rsock_sys_fail_path(const char *, VALUE)); NORETURN(void rsock_sys_fail_sockaddr(const char *, struct sockaddr *addr, socklen_t len)); Index: ruby_2_1/ext/socket/socket.c =================================================================== --- ruby_2_1/ext/socket/socket.c (revision 44841) +++ ruby_2_1/ext/socket/socket.c (revision 44842) @@ -15,6 +15,12 @@ static VALUE sock_s_unpack_sockaddr_in(V https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ext/socket/socket.c#L15 void rsock_sys_fail_host_port(const char *mesg, VALUE host, VALUE port) { + rsock_syserr_fail_host_port(errno, mesg, host, port); +} + +void +rsock_syserr_fail_host_port(int err, const char *mesg, VALUE host, VALUE port) +{ VALUE message; port = rb_String(port); @@ -22,13 +28,20 @@ rsock_sys_fail_host_port(const char *mes https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ext/socket/socket.c#L28 message = rb_sprintf("%s for \"%s\" port %s", mesg, StringValueCStr(host), StringValueCStr(port)); - rb_sys_fail_str(message); + rb_syserr_fail_str(err, message); } void rsock_sys_fail_path(const char *mesg, VALUE path) { + rsock_syserr_fail_path(errno, mesg, path); +} + +void +rsock_syserr_fail_path(int err, const char *mesg, VALUE path) +{ VALUE message; + if (RB_TYPE_P(path, T_STRING)) { if (memchr(RSTRING_PTR(path), '\0', RSTRING_LEN(path))) { path = rb_str_inspect(path); @@ -39,45 +52,64 @@ rsock_sys_fail_path(const char *mesg, VA https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ext/socket/socket.c#L52 message = rb_sprintf("%s for \"%s\"", mesg, StringValueCStr(path)); } - rb_sys_fail_str(message); + rb_syserr_fail_str(err, message); } else { - rb_sys_fail(mesg); + rb_syserr_fail(err, mesg); } } void rsock_sys_fail_sockaddr(const char *mesg, struct sockaddr *addr, socklen_t len) { + rsock_syserr_fail_sockaddr(errno, mesg, addr, len); +} + +void +rsock_syserr_fail_sockaddr(int err, const char *mesg, struct sockaddr *addr, socklen_t len) +{ VALUE rai; rai = rsock_addrinfo_new(addr, len, PF_UNSPEC, 0, 0, Qnil, Qnil); - rsock_sys_fail_raddrinfo(mesg, rai); + rsock_syserr_fail_raddrinfo(err, mesg, rai); } void rsock_sys_fail_raddrinfo(const char *mesg, VALUE rai) { + rsock_syserr_fail_raddrinfo(errno, mesg, rai); +} + +void +rsock_syserr_fail_raddrinfo(int err, const char *mesg, VALUE rai) +{ VALUE str, message; str = rsock_addrinfo_inspect_sockaddr(rai); message = rb_sprintf("%s for %s", mesg, StringValueCStr(str)); - rb_sys_fail_str(message); + rb_syserr_fail_str(err, message); } void rsock_sys_fail_raddrinfo_or_sockaddr(const char *mesg, VALUE addr, VALUE rai) { + rsock_syserr_fail_raddrinfo_or_sockaddr(errno, mesg, addr, rai); +} + +void +rsock_syserr_fail_raddrinfo_or_sockaddr(int err, const char *mesg, VALUE addr, VALUE rai) +{ if (NIL_P(rai)) { StringValue(addr); - rsock_sys_fail_sockaddr(mesg, + + rsock_syserr_fail_sockaddr(err, mesg, (struct sockaddr *)RSTRING_PTR(addr), (socklen_t)RSTRING_LEN(addr)); /* overflow should be checked already */ } else - rsock_sys_fail_raddrinfo(mesg, rai); + rsock_syserr_fail_raddrinfo(err, mesg, rai); } static void Index: ruby_2_1/version.h =================================================================== --- ruby_2_1/version.h (revision 44841) +++ ruby_2_1/version.h (revision 44842) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1 #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-05" -#define RUBY_PATCHLEVEL 19 +#define RUBY_PATCHLEVEL 20 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 Property changes on: ruby_2_1 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r44490,44496 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/