[前][次][番号順一覧][スレッド一覧]

ruby-changes:41857

From: usa <ko1@a...>
Date: Thu, 25 Feb 2016 19:15:42 +0900 (JST)
Subject: [ruby-changes:41857] usa:r53931 (ruby_2_1): merge revision(s) 53561: [Backport #11958]

usa	2016-02-25 19:16:21 +0900 (Thu, 25 Feb 2016)

  New Revision: 53931

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53931

  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_1/
  Modified files:
    branches/ruby_2_1/ChangeLog
    branches/ruby_2_1/ext/socket/option.c
    branches/ruby_2_1/test/socket/test_sockopt.rb
    branches/ruby_2_1/version.h
Index: ruby_2_1/test/socket/test_sockopt.rb
===================================================================
--- ruby_2_1/test/socket/test_sockopt.rb	(revision 53930)
+++ ruby_2_1/test/socket/test_sockopt.rb	(revision 53931)
@@ -23,6 +23,12 @@ class TestSocketOption < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/ruby_2_1/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_1/ChangeLog
===================================================================
--- ruby_2_1/ChangeLog	(revision 53930)
+++ ruby_2_1/ChangeLog	(revision 53931)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1
+Thu Feb 25 18:59:27 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]
+
 Thu Feb 25 18:36:26 2016  NAKAMURA Usaku  <usa@r...>
 
 	* process.c (rb_execarg_parent_start1): need to convert the encoding to
Index: ruby_2_1/ext/socket/option.c
===================================================================
--- ruby_2_1/ext/socket/option.c	(revision 53930)
+++ ruby_2_1/ext/socket/option.c	(revision 53931)
@@ -268,11 +268,16 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ext/socket/option.c#L268
 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_1/version.h
===================================================================
--- ruby_2_1/version.h	(revision 53930)
+++ ruby_2_1/version.h	(revision 53931)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1
 #define RUBY_VERSION "2.1.9"
 #define RUBY_RELEASE_DATE "2016-02-25"
-#define RUBY_PATCHLEVEL 450
+#define RUBY_PATCHLEVEL 451
 
 #define RUBY_RELEASE_YEAR 2016
 #define RUBY_RELEASE_MONTH 2

Property changes on: ruby_2_1
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r53561


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]