From 4df2564519ff410009b60a76eebc99b08f2f08ea Mon Sep 17 00:00:00 2001 From: Tyler Brock Date: Fri, 1 Jun 2012 15:47:10 -0400 Subject: [PATCH] RUBY-444 Additional fix for threading tests to ensure a manager for a new thread is always set. --- lib/mongo/repl_set_connection.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/mongo/repl_set_connection.rb b/lib/mongo/repl_set_connection.rb index 7af05ca..cc3552e 100644 --- a/lib/mongo/repl_set_connection.rb +++ b/lib/mongo/repl_set_connection.rb @@ -401,10 +401,16 @@ module Mongo end end - def get_socket_from_pool(pool_type) - if Thread.current[:managers] && Thread.current[:managers][self] != @manager + def ensure_manager + Thread.current[:managers] ||= Hash.new + + if Thread.current[:managers][self] != @manager Thread.current[:managers][self] = @manager end + end + + def get_socket_from_pool(pool_type) + ensure_manager pool = case pool_type when :primary