diff --git a/History.md b/History.md index 516e25a8..b33b310b 100644 --- a/History.md +++ b/History.md @@ -9,6 +9,7 @@ * Bugfixes * Your bugfix goes here (#Github Number) + * Ignore Rails' reaper thread (and any thread marked forksafe) for warning ([#2475]) * Ignore illegal (by Rack spec) response header ([#2439]) * Close idle connections immediately on shutdown ([#2460]) * Fix some instances of phased restart errors related to the `json` gem (#2473) diff --git a/lib/puma/cluster.rb b/lib/puma/cluster.rb index 189a9267..c2eff7da 100644 --- a/lib/puma/cluster.rb +++ b/lib/puma/cluster.rb @@ -331,13 +331,15 @@ module Puma log "* Process workers: #{@options[:workers]}" - before = Thread.list + # Threads explicitly marked as fork safe will be ignored. + # Used in Rails, but may be used by anyone. + before = Thread.list.reject { |t| t.thread_variable_get(:fork_safe) } if preload? log "* Preloading application" load_and_bind - after = Thread.list + after = Thread.list.reject { |t| t.thread_variable_get(:fork_safe) } if after.size > before.size threads = (after - before)