[Groonga-commit] droonga/droonga-client-ruby at 8d17b17 [master] Receiver#receive should exit when enough messages are received

Back to archive index

YUKI Hiroshi null+****@clear*****
Mon Oct 28 20:22:12 JST 2013


YUKI Hiroshi	2013-10-28 20:22:12 +0900 (Mon, 28 Oct 2013)

  New Revision: 8d17b1775e1c563ab1679fa42c0f69d8c4a0b9d1
  https://github.com/droonga/droonga-client-ruby/commit/8d17b1775e1c563ab1679fa42c0f69d8c4a0b9d1

  Message:
    Receiver#receive should exit when enough messages are received

  Modified files:
    lib/droonga/client/connection/droonga_protocol.rb

  Modified: lib/droonga/client/connection/droonga_protocol.rb (+3 -1)
===================================================================
--- lib/droonga/client/connection/droonga_protocol.rb    2013-10-28 20:16:54 +0900 (b97ab52)
+++ lib/droonga/client/connection/droonga_protocol.rb    2013-10-28 20:22:12 +0900 (b75092e)
@@ -53,7 +53,7 @@ module Droonga
             envelope = envelope.dup
             envelope["replyTo"] = "#{receiver.host}:#{receiver.port}/droonga"
             @logger.post("message", envelope)
-            receiver.receive(:timeout => @timeout).first
+            receiver.receive(:timeout => @timeout, :wait_for => 1).first
           ensure
             receiver.close
           end
@@ -82,12 +82,14 @@ module Droonga
           end
 
           def receive(options={})
+            waiting_count = options[:wait_for] || 1
             if IO.select([@socket], nil, nil, options[:timeout])
               client =****@socke*****
               messages = []
               unpacker = MessagePack::Unpacker.new(client)
               unpacker.each do |object|
                 messages << object
+                break if messages.size >= waiting_count
               end
               client.close
               messages
-------------- next part --------------
HTML����������������������������...
Download 



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