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

ruby-changes:39416

From: tenderlove <ko1@a...>
Date: Thu, 6 Aug 2015 08:17:38 +0900 (JST)
Subject: [ruby-changes:39416] tenderlove:r51497 (trunk): * ext/openssl/lib/openssl/ssl.rb (module OpenSSL): move

tenderlove	2015-08-06 08:17:33 +0900 (Thu, 06 Aug 2015)

  New Revision: 51497

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

  Log:
    * ext/openssl/lib/openssl/ssl.rb (module OpenSSL): move
      SSLSocket#sysclose to Ruby.
    
    * ext/openssl/ossl_ssl.c (ossl_ssl_close): ditto

  Modified files:
    trunk/ChangeLog
    trunk/ext/openssl/lib/openssl/ssl.rb
    trunk/ext/openssl/ossl_ssl.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 51496)
+++ ChangeLog	(revision 51497)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Aug  6 08:15:49 2015  Aaron Patterson <tenderlove@r...>
+
+	* ext/openssl/lib/openssl/ssl.rb (module OpenSSL): move
+	  SSLSocket#sysclose to Ruby.
+
+	* ext/openssl/ossl_ssl.c (ossl_ssl_close): ditto
+
 Thu Aug  6 07:57:21 2015  Aaron Patterson <tenderlove@r...>
 
 	* ext/openssl/lib/openssl/ssl.rb (module OpenSSL): move nonblock
Index: ext/openssl/ossl_ssl.c
===================================================================
--- ext/openssl/ossl_ssl.c	(revision 51496)
+++ ext/openssl/ossl_ssl.c	(revision 51497)
@@ -68,7 +68,6 @@ static VALUE eSSLErrorWaitWritable; https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_ssl.c#L68
 
 #define ossl_ssl_get_io(o)           rb_iv_get((o),"@io")
 #define ossl_ssl_get_ctx(o)          rb_iv_get((o),"@context")
-#define ossl_ssl_get_sync_close(o)   rb_iv_get((o),"@sync_close")
 #define ossl_ssl_get_x509(o)         rb_iv_get((o),"@x509")
 #define ossl_ssl_get_key(o)          rb_iv_get((o),"@key")
 
@@ -1590,31 +1589,25 @@ ossl_ssl_write_nonblock(int argc, VALUE https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_ssl.c#L1589
 
 /*
  * call-seq:
- *    ssl.sysclose => nil
+ *    ssl.stop => nil
  *
- * Shuts down the SSL connection and prepares it for another connection.
+ * Stops the SSL connection and prepares it for another connection.
  */
 static VALUE
-ossl_ssl_close(VALUE self)
+ossl_ssl_stop(VALUE self)
 {
     SSL *ssl;
-    VALUE io;
 
     /* ossl_ssl_data_get_struct() is not usable here because it may return
      * from this function; */
 
     GetSSL(self, ssl);
 
-    io = ossl_ssl_get_io(self);
-    if (!RTEST(rb_funcall(io, rb_intern("closed?"), 0))) {
-        if (ssl) {
-            ossl_ssl_shutdown(ssl);
-            SSL_free(ssl);
-        }
-        DATA_PTR(self) = NULL;
-        if (RTEST(ossl_ssl_get_sync_close(self)))
-            rb_funcall(io, rb_intern("close"), 0);
+    if (ssl) {
+	ossl_ssl_shutdown(ssl);
+	SSL_free(ssl);
     }
+    DATA_PTR(self) = NULL;
 
     return Qnil;
 }
@@ -2287,7 +2280,7 @@ Init_ossl_ssl(void) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_ssl.c#L2280
     rb_define_private_method(cSSLSocket, "sysread_nonblock",    ossl_ssl_read_nonblock, -1);
     rb_define_method(cSSLSocket, "syswrite",   ossl_ssl_write, 1);
     rb_define_private_method(cSSLSocket, "syswrite_nonblock",    ossl_ssl_write_nonblock, -1);
-    rb_define_method(cSSLSocket, "sysclose",   ossl_ssl_close, 0);
+    rb_define_private_method(cSSLSocket, "stop",   ossl_ssl_stop, 0);
     rb_define_method(cSSLSocket, "cert",       ossl_ssl_get_cert, 0);
     rb_define_method(cSSLSocket, "peer_cert",  ossl_ssl_get_peer_cert, 0);
     rb_define_method(cSSLSocket, "peer_cert_chain", ossl_ssl_get_peer_cert_chain, 0);
Index: ext/openssl/lib/openssl/ssl.rb
===================================================================
--- ext/openssl/lib/openssl/ssl.rb	(revision 51496)
+++ ext/openssl/lib/openssl/ssl.rb	(revision 51497)
@@ -291,6 +291,16 @@ module OpenSSL https://github.com/ruby/ruby/blob/trunk/ext/openssl/lib/openssl/ssl.rb#L291
         end
       end
 
+      # call-seq:
+      #    ssl.sysclose => nil
+      #
+      # Shuts down the SSL connection and prepares it for another connection.
+      def sysclose
+        return if closed?
+        stop
+        io.close if sync_close
+      end
+
       ##
       # Perform hostname verification after an SSL connection is established
       #

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

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