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

Fix Rack::Lock mutex usage #2

Closed
wants to merge 2 commits into from
Closed

Conversation

dkubb
Copy link
Owner

@dkubb dkubb commented Mar 25, 2015

This branch fixes how Rack::Lock uses the mutex and resolves some problems with Rack::Timeout as a result.

* In the previous code if a lock is being waited on and an error was
  raised, such as by Rack::Timeout, the original code would attempt to
  unlock a mutex it does not own raising a ThreadError with the error
  message "Attempt to unlock a mutex which is locked by another thread"

  This code uses an explicit begin block that starts immediately after
  the mutex is locked so that when the ensure part runs we know that
  the mutex belongs to this thread.
* The original code would set the flag for the duration of
  Rack::Lock#call and then set it back when the method finished. The
  problem is that the BodyProxy could be executing code that relies on
  the state of the flag.

  This change makes sure the application *and* the body proxy see the
  expected state of the environment.
@dkubb dkubb added the bug label Mar 25, 2015
@dkubb dkubb self-assigned this Mar 25, 2015
@dkubb dkubb mentioned this pull request Mar 25, 2015
@dkubb dkubb force-pushed the fix/rack-lock-mutex-usage branch 2 times, most recently from df97367 to c1aefd8 Compare March 25, 2015 17:58
@dkubb
Copy link
Owner Author

dkubb commented Mar 25, 2015

Moved to #3

@dkubb dkubb closed this Mar 25, 2015
@dkubb dkubb deleted the fix/rack-lock-mutex-usage branch March 25, 2015 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant