ruby-changes:41993
From: nagachika <ko1@a...>
Date: Wed, 9 Mar 2016 22:45:39 +0900 (JST)
Subject: [ruby-changes:41993] nagachika:r54067 (ruby_2_2): merge revision(s) 53561: [Backport #11958]
nagachika 2016-03-09 22:45:33 +0900 (Wed, 09 Mar 2016) New Revision: 54067 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54067 Log: merge revision(s) 53561: [Backport #11958] * ext/socket/option.c (sockopt_bool): relax boolean size to be one too not only sizeof(int). Winsock getsockopt() returns a single byte as a boolean socket option. [ruby-core:72730] [Bug #11958] Modified directories: branches/ruby_2_2/ Modified files: branches/ruby_2_2/ChangeLog branches/ruby_2_2/ext/socket/option.c branches/ruby_2_2/test/socket/test_sockopt.rb branches/ruby_2_2/version.h Index: ruby_2_2/ext/socket/option.c =================================================================== --- ruby_2_2/ext/socket/option.c (revision 54066) +++ ruby_2_2/ext/socket/option.c (revision 54067) @@ -301,11 +301,16 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ext/socket/option.c#L301 sockopt_bool(VALUE self) { int i; + long len; VALUE data = sockopt_data(self); StringValue(data); - if (RSTRING_LEN(data) != sizeof(int)) + len = RSTRING_LEN(data); + if (len == 1) { + return *RSTRING_PTR(data) == 0 ? Qfalse : Qtrue; + } + if (len != sizeof(int)) rb_raise(rb_eTypeError, "size differ. expected as sizeof(int)=%d but %ld", - (int)sizeof(int), (long)RSTRING_LEN(data)); + (int)sizeof(int), (long)len); memcpy((char*)&i, RSTRING_PTR(data), sizeof(int)); return i == 0 ? Qfalse : Qtrue; } Index: ruby_2_2/version.h =================================================================== --- ruby_2_2/version.h (revision 54066) +++ ruby_2_2/version.h (revision 54067) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1 #define RUBY_VERSION "2.2.5" #define RUBY_RELEASE_DATE "2016-03-09" -#define RUBY_PATCHLEVEL 250 +#define RUBY_PATCHLEVEL 251 #define RUBY_RELEASE_YEAR 2016 #define RUBY_RELEASE_MONTH 3 Index: ruby_2_2/test/socket/test_sockopt.rb =================================================================== --- ruby_2_2/test/socket/test_sockopt.rb (revision 54066) +++ ruby_2_2/test/socket/test_sockopt.rb (revision 54067) @@ -23,6 +23,12 @@ class TestSocketOption < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/socket/test_sockopt.rb#L23 assert_equal(true, opt.bool) opt = Socket::Option.int(:INET, :SOCKET, :KEEPALIVE, 2) assert_equal(true, opt.bool) + Socket.open(:INET, :STREAM) {|s| + s.setsockopt(Socket::Option.bool(:INET, :SOCKET, :KEEPALIVE, true)) + assert_equal(true, s.getsockopt(Socket::SOL_SOCKET, Socket::SO_KEEPALIVE).bool) + s.setsockopt(Socket::Option.bool(:INET, :SOCKET, :KEEPALIVE, false)) + assert_equal(false, s.getsockopt(Socket::SOL_SOCKET, Socket::SO_KEEPALIVE).bool) + } end def test_ipv4_multicast_loop Index: ruby_2_2/ChangeLog =================================================================== --- ruby_2_2/ChangeLog (revision 54066) +++ ruby_2_2/ChangeLog (revision 54067) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1 +Wed Mar 9 22:26:38 2016 Nobuyoshi Nakada <nobu@r...> + + * ext/socket/option.c (sockopt_bool): relax boolean size to be one + too not only sizeof(int). Winsock getsockopt() returns a single + byte as a boolean socket option. [ruby-core:72730] [Bug #11958] + Wed Mar 9 05:14:20 2016 Eric Wong <e@8...> * io.c (io_getpartial): remove unused kwarg from template Property changes on: ruby_2_2 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r53561 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/