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

InternalPool is not properly synchronized #418

Closed
cheald opened this issue May 8, 2014 · 2 comments
Closed

InternalPool is not properly synchronized #418

cheald opened this issue May 8, 2014 · 2 comments

Comments

@cheald
Copy link
Contributor

cheald commented May 8, 2014

There are a number of potential issues with InternalPool, particularly in relation to #create being public, #each, #to_a, #busy_size, and #idle_size being unsynchronized, and #busy_size and #idle_size creating intermediate arrays rather than using Array#count.

@tarcieri
Copy link
Member

tarcieri commented May 8, 2014

Yes, this is bad, and I feel bad. I'm not sure how I didn't notice this in the PRs that changed this code. InternalPool's contract is definitely to be thread safe, and it's not honoring that.

  • #create should probably be private and never be called in an unsynchronized context
  • #to_a should do something like acquire the mutex then duplicate the original list of threads
  • #each could use #to_a to obtain its own copy of the thread list, then iterate it unsynchronized
  • #busy_size and #idle_size should probably just keep memoized counters which can be safely read without synchronizing

@cheald
Copy link
Contributor Author

cheald commented Jul 19, 2014

This is invalid as #449 is merged.

@cheald cheald closed this as completed Jul 19, 2014
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

2 participants