[Groonga-commit] droonga/droonga-engine at 0749638 [master] Flush buffered chunks as many as possible

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Jul 14 23:14:56 JST 2014


Kouhei Sutou	2014-07-14 23:14:56 +0900 (Mon, 14 Jul 2014)

  New Revision: 0749638e74f4bd60ffce4779125a510795a296dc
  https://github.com/droonga/droonga-engine/commit/0749638e74f4bd60ffce4779125a510795a296dc

  Message:
    Flush buffered chunks as many as possible

  Modified files:
    lib/droonga/buffered_tcp_socket.rb

  Modified: lib/droonga/buffered_tcp_socket.rb (+15 -10)
===================================================================
--- lib/droonga/buffered_tcp_socket.rb    2014-07-02 10:06:38 +0900 (afb2859)
+++ lib/droonga/buffered_tcp_socket.rb    2014-07-14 23:14:56 +0900 (25865c1)
@@ -47,19 +47,24 @@ module Droonga
     end
 
     def on_writable
-      begin
+      until @_write_buffer.empty?
         chunk = @_write_buffer.shift
-        written_size = @_io.write(chunk.data)
-        if written_size == chunk.data.bytesize
-          chunk.written
-        else
-          chunk.written_partial(written_size)
+        begin
+          written_size = @_io.write_nonblock(chunk.data)
+          if written_size == chunk.data.bytesize
+            chunk.written
+          else
+            chunk.written_partial(written_size)
+            @_write_buffer.unshift(chunk)
+            break
+          end
+        rescue Errno::EINTR
           @_write_buffer.unshift(chunk)
+          return
+        rescue SystemCallError, IOError, SocketError
+          @_write_buffer.unshift(chunk)
+          return close
         end
-      rescue Errno::EINTR
-        return
-      rescue SystemCallError, IOError, SocketError
-        return close
       end
 
       if @_write_buffer.empty?
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index