mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Clean thread locals when using keepalive. Fixes #823
This commit is contained in:
parent
bca2c99f30
commit
61294479b2
2 changed files with 10 additions and 3 deletions
|
@ -399,6 +399,7 @@ module Puma
|
||||||
#
|
#
|
||||||
def process_client(client, buffer)
|
def process_client(client, buffer)
|
||||||
begin
|
begin
|
||||||
|
clean_thread_locals = @options[:clean_thread_locals]
|
||||||
close_socket = true
|
close_socket = true
|
||||||
|
|
||||||
while true
|
while true
|
||||||
|
@ -412,6 +413,8 @@ module Puma
|
||||||
return unless @queue_requests
|
return unless @queue_requests
|
||||||
buffer.reset
|
buffer.reset
|
||||||
|
|
||||||
|
ThreadPool.clean_thread_locals if clean_thread_locals
|
||||||
|
|
||||||
unless client.reset(@status == :run)
|
unless client.reset(@status == :run)
|
||||||
close_socket = false
|
close_socket = false
|
||||||
client.set_timeout @persistent_timeout
|
client.set_timeout @persistent_timeout
|
||||||
|
|
|
@ -45,6 +45,12 @@ module Puma
|
||||||
attr_reader :spawned, :trim_requested
|
attr_reader :spawned, :trim_requested
|
||||||
attr_accessor :clean_thread_locals
|
attr_accessor :clean_thread_locals
|
||||||
|
|
||||||
|
def self.clean_thread_locals
|
||||||
|
Thread.current.keys.each do |key|
|
||||||
|
Thread.current[key] = nil unless key == :__recursive_key__
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# How many objects have yet to be processed by the pool?
|
# How many objects have yet to be processed by the pool?
|
||||||
#
|
#
|
||||||
def backlog
|
def backlog
|
||||||
|
@ -98,9 +104,7 @@ module Puma
|
||||||
break unless continue
|
break unless continue
|
||||||
|
|
||||||
if @clean_thread_locals
|
if @clean_thread_locals
|
||||||
Thread.current.keys.each do |key|
|
ThreadPool.clean_thread_locals
|
||||||
Thread.current[key] = nil unless key == :__recursive_key__
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue