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 ConnectionPool thread-safe issue #1200

Closed
wants to merge 2 commits into from
Closed

Fix ConnectionPool thread-safe issue #1200

wants to merge 2 commits into from

Conversation

xli
Copy link

@xli xli commented May 22, 2011

This is a new fix NZKoz suggested, details: #563

Changes made: covered ConnectionPool#connection and #release_connection methods by mutex to fix thread-safe issue; changed ConnectionPool#clear_stale_cached_connections! to private to avoid outside call, which would not be thread-safe,

The old patch with the test provided to prove the thread-safe issue on jruby can be found at: xli@23828c0

…mutex to fix thread-safe issue; changed ConnectionPool#clear_stale_cached_connections! to private to avoid outside call, which would not be thread-safe
@josevalim
Copy link
Contributor

Is it intentional to make the method private?

@tenderlove
Copy link
Member

This can't pass tests. We have tests that call the method you made private.

@xli
Copy link
Author

xli commented May 22, 2011

Tenderlove, please look into my changes, I also changed the test, using send instead.

josevalim: it is intentional to make the method private, because the method is not thread-safe called outside of ConnectionPool, all methods called inside ConnectionPool are covered by mutex, so there is no sense to leave the method public

@dasch
Copy link
Contributor

dasch commented May 25, 2011

Is the mutex reentrant? If so, would it be feasible to synchronize #clear_stale_cached_connections! as well?

Using #send from the tests is smelly.

@xli
Copy link
Author

xli commented May 28, 2011

Hi, since there are some concerns about making #clear_stale_cached_connections! private, I rollbacked the changes related with it, so that this pull request can focus on the fix for #connection and #release_connection methods

jake3030 pushed a commit to jake3030/rails that referenced this pull request Jun 28, 2011
Certain groups of web proxies do not set these values properly.  Notably,
proxies for cell phones, which often do not set the remote IP information
correctly (not surprisingly, since the clients do not have an IP address).

Allowing this to be configurable makes it possible for developers to choose
to ignore this simple spoofing check, when a significant amount of their
traffic would result in false positives anyway.

Signed-off-by: Michael Koziarski <michael@koziarski.com>

[rails#1200 state:committed]
@sikachu
Copy link
Member

sikachu commented Jul 11, 2011

Do you mind squashed those commits together and force push to your branch?

@tenderlove bro, does the change looks ok?

@tenderlove
Copy link
Member

Ya, this is fine. I'll merge it.

@rafaelfranca
Copy link
Member

@tenderlove can I close this one?

@tenderlove
Copy link
Member

Ya, we can close this. Those methods are synchronized on master now.

@tenderlove tenderlove closed this Apr 27, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants