Permalink
Browse files

Add ability to wakeup and cancel persistent connections

Without this, the graceful stop code has to wait for the persistent
timeout to expire even though there is actually no work going on.
  • Loading branch information...
1 parent 0985a07 commit 3f529f073122aeca8757860987b043e8647b0923 @evanphx evanphx committed Dec 8, 2011
Showing with 6 additions and 1 deletion.
  1. 0 bin/pumactl
  2. +6 −1 lib/puma/server.rb
View
0 bin/pumactl 100644 → 100755
No changes.
View
@@ -52,6 +52,7 @@ def initialize(app, events=Events::DEFAULT)
@thread_pool = nil
@persistent_timeout = PERSISTENT_TIMEOUT
+ @persistent_check, @persistent_wakeup = IO.pipe
@proto_env = {
"rack.version".freeze => Rack::VERSION,
@@ -219,9 +220,11 @@ def process_client(client)
env = @proto_env.dup
nparsed = 0
else
- unless IO.select([client], nil, nil, @persistent_timeout)
+ unless ret = IO.select([client, @persistent_check], nil, nil, @persistent_timeout)
raise EOFError, "Timed out persistent connection"
end
+
+ return if ret.first.include? @persistent_check
end
else
# Parser is not done, queue up more data to read and continue parsing
@@ -514,12 +517,14 @@ def graceful_shutdown
# off the request queue before finally exiting.
#
def stop(sync=false)
+ @persistent_wakeup.close
@notify << STOP_COMMAND
@thread.join if @thread && sync
end
def halt(sync=false)
+ @persistent_wakeup.close
@notify << HALT_COMMAND
@thread.join if @thread && sync

0 comments on commit 3f529f0

Please sign in to comment.