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

ruby-changes:34498

From: usa <ko1@a...>
Date: Fri, 27 Jun 2014 17:17:46 +0900 (JST)
Subject: [ruby-changes:34498] usa:r46579 (ruby_2_0_0): merge revision(s) 45863, 45871: [Backport #9750]

usa	2014-06-27 17:17:35 +0900 (Fri, 27 Jun 2014)

  New Revision: 46579

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

  Log:
    merge revision(s) 45863,45871: [Backport #9750]
    
    * ext/openssl/lib/openssl/ssl.rb (OpenSSL::SSL::SSLServer#accept):
      Consider Socket#accept as well as TCPServer#accept.
      Reported by Sam Stelfox.  [ruby-core:62064] [Bug #9750]

  Modified directories:
    branches/ruby_2_0_0/
  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/ext/openssl/lib/openssl/ssl.rb
    branches/ruby_2_0_0/test/openssl/test_pair.rb
    branches/ruby_2_0_0/version.h
Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 46578)
+++ ruby_2_0_0/ChangeLog	(revision 46579)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Fri Jun 27 17:15:36 2014  Tanaka Akira  <akr@f...>
+
+	* ext/openssl/lib/openssl/ssl.rb (OpenSSL::SSL::SSLServer#accept):
+	  Consider Socket#accept as well as TCPServer#accept.
+	  Reported by Sam Stelfox.  [ruby-core:62064] [Bug #9750]
+
 Fri Jun 27 17:12:45 2014  Eric Wong  <e@8...>
 
 	* complex.c (parse_comp): replace ALLOCA_N with ALLOCV_N/ALLOCV_END
Index: ruby_2_0_0/ext/openssl/lib/openssl/ssl.rb
===================================================================
--- ruby_2_0_0/ext/openssl/lib/openssl/ssl.rb	(revision 46578)
+++ ruby_2_0_0/ext/openssl/lib/openssl/ssl.rb	(revision 46579)
@@ -177,7 +177,10 @@ module OpenSSL https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/openssl/lib/openssl/ssl.rb#L177
       end
 
       def accept
-        sock = @svr.accept
+        # Socket#accept returns [socket, addrinfo].
+        # TCPServer#accept returns a socket.
+        # The following comma strips addrinfo.
+        sock, = @svr.accept
         begin
           ssl = OpenSSL::SSL::SSLSocket.new(sock, @ctx)
           ssl.sync_close = true
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 46578)
+++ ruby_2_0_0/version.h	(revision 46579)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
 #define RUBY_RELEASE_DATE "2014-06-27"
-#define RUBY_PATCHLEVEL 503
+#define RUBY_PATCHLEVEL 504
 
 #define RUBY_RELEASE_YEAR 2014
 #define RUBY_RELEASE_MONTH 6
Index: ruby_2_0_0/test/openssl/test_pair.rb
===================================================================
--- ruby_2_0_0/test/openssl/test_pair.rb	(revision 46578)
+++ ruby_2_0_0/test/openssl/test_pair.rb	(revision 46579)
@@ -5,14 +5,14 @@ if defined?(OpenSSL) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/openssl/test_pair.rb#L5
 require 'socket'
 require_relative '../ruby/ut_eof'
 
-module SSLPair
+module OpenSSL::SSLPairM
   def server
     host = "127.0.0.1"
     port = 0
     ctx = OpenSSL::SSL::SSLContext.new()
     ctx.ciphers = "ADH"
     ctx.tmp_dh_callback = proc { OpenSSL::TestUtils::TEST_KEY_DH1024 }
-    tcps = TCPServer.new(host, port)
+    tcps = create_tcp_server(host, port)
     ssls = OpenSSL::SSL::SSLServer.new(tcps, ctx)
     return ssls
   end
@@ -21,7 +21,7 @@ module SSLPair https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/openssl/test_pair.rb#L21
     host = "127.0.0.1"
     ctx = OpenSSL::SSL::SSLContext.new()
     ctx.ciphers = "ADH"
-    s = TCPSocket.new(host, port)
+    s = create_tcp_client(host, port)
     ssl = OpenSSL::SSL::SSLSocket.new(s, ctx)
     ssl.connect
     ssl.sync_close = true
@@ -35,7 +35,7 @@ module SSLPair https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/openssl/test_pair.rb#L35
       ssls.close
       ns
     }
-    port = ssls.to_io.addr[1]
+    port = ssls.to_io.local_address.ip_port
     c = client(port)
     s = th.value
     if block_given?
@@ -56,10 +56,31 @@ module SSLPair https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/openssl/test_pair.rb#L56
   end
 end
 
-class OpenSSL::TestEOF1 < Test::Unit::TestCase
-  include TestEOF
-  include SSLPair
+module OpenSSL::SSLPair
+  include OpenSSL::SSLPairM
+
+  def create_tcp_server(host, port)
+    TCPServer.new(host, port)
+  end
+
+  def create_tcp_client(host, port)
+    TCPSocket.new(host, port)
+  end
+end
+
+module OpenSSL::SSLPairLowlevelSocket
+  include OpenSSL::SSLPairM
+
+  def create_tcp_server(host, port)
+    Addrinfo.tcp(host, port).listen
+  end
 
+  def create_tcp_client(host, port)
+    Addrinfo.tcp(host, port).connect
+  end
+end
+
+module OpenSSL::TestEOF1M
   def open_file(content)
     s1, s2 = ssl_pair
     Thread.new { s2 << content; s2.close }
@@ -67,10 +88,7 @@ class OpenSSL::TestEOF1 < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/openssl/test_pair.rb#L88
   end
 end
 
-class OpenSSL::TestEOF2 < Test::Unit::TestCase
-  include TestEOF
-  include SSLPair
-
+module OpenSSL::TestEOF2M
   def open_file(content)
     s1, s2 = ssl_pair
     Thread.new { s1 << content; s1.close }
@@ -78,9 +96,7 @@ class OpenSSL::TestEOF2 < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/openssl/test_pair.rb#L96
   end
 end
 
-class OpenSSL::TestPair < Test::Unit::TestCase
-  include SSLPair
-
+module OpenSSL::TestPairM
   def test_getc
     ssl_pair {|s1, s2|
       s1 << "a"
@@ -243,7 +259,40 @@ class OpenSSL::TestPair < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/openssl/test_pair.rb#L259
     sock1.close if sock1 && !sock1.closed?
     sock2.close if sock2 && !sock2.closed?
   end
+end
+
+class OpenSSL::TestEOF1 < Test::Unit::TestCase
+  include TestEOF
+  include OpenSSL::SSLPair
+  include OpenSSL::TestEOF1M
+end
+
+class OpenSSL::TestEOF1LowlevelSocket < Test::Unit::TestCase
+  include TestEOF
+  include OpenSSL::SSLPairLowlevelSocket
+  include OpenSSL::TestEOF1M
+end
+
+class OpenSSL::TestEOF2 < Test::Unit::TestCase
+  include TestEOF
+  include OpenSSL::SSLPair
+  include OpenSSL::TestEOF2M
+end
+
+class OpenSSL::TestEOF2LowlevelSocket < Test::Unit::TestCase
+  include TestEOF
+  include OpenSSL::SSLPairLowlevelSocket
+  include OpenSSL::TestEOF2M
+end
+
+class OpenSSL::TestPair < Test::Unit::TestCase
+  include OpenSSL::SSLPair
+  include OpenSSL::TestPairM
+end
 
+class OpenSSL::TestPairLowlevelSocket < Test::Unit::TestCase
+  include OpenSSL::SSLPairLowlevelSocket
+  include OpenSSL::TestPairM
 end
 
 end

Property changes on: ruby_2_0_0
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r45863,45871


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

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