[Groonga-commit] droonga/droonga-engine at 139c5e1 [master] stop_gracefully: Wait until all clients are disconnected

Back to archive index

YUKI Hiroshi null+****@clear*****
Wed Apr 22 15:32:28 JST 2015


YUKI Hiroshi	2015-04-22 15:32:28 +0900 (Wed, 22 Apr 2015)

  New Revision: 139c5e10586e9bdb9d5fd0c0199f39a655451082
  https://github.com/droonga/droonga-engine/commit/139c5e10586e9bdb9d5fd0c0199f39a655451082

  Message:
    stop_gracefully: Wait until all clients are disconnected

  Modified files:
    lib/droonga/command/droonga_engine_service.rb
    lib/droonga/fluent_message_receiver.rb

  Modified: lib/droonga/command/droonga_engine_service.rb (+2 -2)
===================================================================
--- lib/droonga/command/droonga_engine_service.rb    2015-04-22 11:59:59 +0900 (b9a6882)
+++ lib/droonga/command/droonga_engine_service.rb    2015-04-22 15:32:28 +0900 (ca3292d)
@@ -213,15 +213,15 @@ module Droonga
         return if @stopping
         logger.trace("stop_gracefully: start")
         @stopping = true
-        @receiver.stop_gracefully
+        @receiver.stop_gracefully do
         @engine.stop_gracefully do
           shutdown_worker_process_agent
           shutdown_internal_message_receiver
-          @receiver.shutdown_clients
           logger.trace("stop_gracefully: done",
                        :n_rest_watchers => @loop.watchers.size,
                        :rest_watchers   => @loop.watchers)
         end
+        end
       end
 
       # It may be called after stop_gracefully.

  Modified: lib/droonga/fluent_message_receiver.rb (+12 -1)
===================================================================
--- lib/droonga/fluent_message_receiver.rb    2015-04-22 11:59:59 +0900 (9d87318)
+++ lib/droonga/fluent_message_receiver.rb    2015-04-22 15:32:28 +0900 (d5febe0)
@@ -31,6 +31,7 @@ module Droonga
       @server = nil
       @clients = []
       @on_message = on_message
+      @on_shutdown_ready = nil
     end
 
     def start
@@ -40,11 +41,18 @@ module Droonga
       logger.trace("start: done")
     end
 
-    def stop_gracefully
+    def stop_gracefully(&block)
       logger.trace("stop_gracefully: start")
       shutdown_heartbeat_receiver
       logger.trace("stop_gracefully: middle")
       shutdown_server
+      if****@clien*****?
+        yield
+      elsif block_given?
+        @on_shutdown_ready = lambda do
+          yield
+        end
+      end
       logger.trace("stop_gracefully: done")
     end
 
@@ -87,6 +95,9 @@ module Droonga
         end
         client.on_close = lambda do
           @clients.delete(client)
+          if @on_shutdown_ready and****@clien*****?
+            @on_shutdown_ready.call
+          end
         end
         @clients << client
       end
-------------- next part --------------
HTML����������������������������...
Télécharger 



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