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

ruby-changes:34710

From: kosaki <ko1@a...>
Date: Sat, 12 Jul 2014 04:22:28 +0900 (JST)
Subject: [ruby-changes:34710] kosaki:r46793 (trunk): * lib/net/smtp.rb (Net::SMTP#data): enable buffering while

kosaki	2014-07-12 04:22:19 +0900 (Sat, 12 Jul 2014)

  New Revision: 46793

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

  Log:
    * lib/net/smtp.rb (Net::SMTP#data): enable buffering while
      'data' send for optimizing Net::SMTP#send_message.
      [ruby-dev:48329] [misc #9981]
      patch by Masahiro Tomita.

  Modified files:
    trunk/ChangeLog
    trunk/lib/net/smtp.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 46792)
+++ ChangeLog	(revision 46793)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Jul 12 04:17:40 2014  KOSAKI Motohiro  <kosaki.motohiro@g...>
+
+	* lib/net/smtp.rb (Net::SMTP#data): enable buffering while
+	  'data' send for optimizing Net::SMTP#send_message.
+	  [ruby-dev:48329] [misc #9981]
+	  patch by Masahiro Tomita.
+
 Sat Jul 12 01:13:45 2014  Naohisa Goto  <ngotogenome@g...>
 
 	* test/ruby/envutil.rb (assert_no_memory_leak): On Solaris 9 or later,
Index: lib/net/smtp.rb
===================================================================
--- lib/net/smtp.rb	(revision 46792)
+++ lib/net/smtp.rb	(revision 46793)
@@ -901,10 +901,17 @@ module Net https://github.com/ruby/ruby/blob/trunk/lib/net/smtp.rb#L901
       end
       res = critical {
         check_continue get_response('DATA')
-        if msgstr
-          @socket.write_message msgstr
-        else
-          @socket.write_message_by_block(&block)
+        socket_sync_bak = @socket.io.sync
+        begin
+          @socket.io.sync = false
+          if msgstr
+            @socket.write_message msgstr
+          else
+            @socket.write_message_by_block(&block)
+          end
+        ensure
+          @socket.io.flush
+          @socket.io.sync = socket_sync_bak
         end
         recv_response()
       }

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

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