mongodb/mongo-ruby-driver — pull request #399 by estolfo (2014-03-25 16:05:08+00:00)
Title: RUBY-736 Clone sets and lists of pools before returning in PoolManager

This pull request addresses the need for thread-safe reads on certain pool manager attributes. These changes will avoid a situation in which someone is iterating through a list of pools associated with a pool manager while the pool manager is trying to connect and simultaneously mutating one of the lists.

Anyone looking to get a snapshot of the replica set state with consistency between lists should use the #state_snapshot method on a PoolManager instance. For individual access to the lists, the explicit methods can be used (such as #pools, #secondaries, #arbiters, etc)

Note that #clone in Ruby is a shallow copy, so only the actual list is cloned, not the list members themselves.

Tests are passing: https://jenkins.10gen.com/job/mongo-ruby-driver-emily/3246/