Permalink
Browse files

Merge pull request #55 from ehlertij/master

Allow soft termination signal to be sent more than once
  • Loading branch information...
2 parents daa4e97 + 5d64dbb commit f51c1f515d83175b59186c6d0badaa0a41365e40 @FooBarWidget FooBarWidget committed Jun 5, 2012
Showing with 11 additions and 8 deletions.
  1. +11 −8 lib/phusion_passenger/abstract_request_handler.rb
@@ -331,14 +331,17 @@ def start_main_loop_thread
# May only be called while the main loop is running. May be called
# from any thread.
def soft_shutdown
- @select_timeout = @soft_termination_linger_time
- @graceful_termination_pipe[1].close rescue nil
- if @detach_key && @pool_account_username && @pool_account_password
- client = MessageClient.new(@pool_account_username, @pool_account_password)
- begin
- client.detach(@detach_key)
- ensure
- client.close
+ unless @soft_terminated
+ @soft_terminated = true
+ @select_timeout = @soft_termination_linger_time
+ @graceful_termination_pipe[1].close rescue nil
+ if @detach_key && @pool_account_username && @pool_account_password
+ client = MessageClient.new(@pool_account_username, @pool_account_password)
+ begin
+ client.detach(@detach_key)
+ ensure
+ client.close
+ end
end
end
end

0 comments on commit f51c1f5

Please sign in to comment.