Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rack::Cache is not multithread friendly #70

Open
jtblin opened this issue Aug 4, 2012 · 0 comments
Open

Rack::Cache is not multithread friendly #70

jtblin opened this issue Aug 4, 2012 · 0 comments

Comments

@jtblin
Copy link
Contributor

jtblin commented Aug 4, 2012

When using puma with Rack::Cache, the assets do not get loaded correctly, this issue is described on the puma project: puma/puma#57

I found out that puma sets env['rack.run_once'] to true and rack-cache uses this information to determine to run the request on a non threadsafe mode, i.e. in /lib/rack/cache/context.rb:48.

def call(env)
  if env['rack.run_once'] 
    call! env
  else
    clone.call! env
  end
end

As per rack specs (http://rack.rubyforge.org/doc/files/SPEC.html), rack.run_once is not a guaranty that the application will be served only once. The specs also describe rack.multithread if the application object may be simultaneously invoked by another thread in the same process. I'll send a pull request to add test that rack.multithread is not set to true i.e.

def call(env)
  if env['rack.run_once'] && !env['rack.multithread']
    call! env
  else
    clone.call! env
  end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant