From 06b682ec7c8ecdc4c806f4f7f0a51a0f5b05c342 Mon Sep 17 00:00:00 2001 From: Kyle Banker Date: Tue, 6 Dec 2011 14:38:56 -0500 Subject: [PATCH] RUBY-383 do a sync_refresh before checking out a socket --- lib/mongo/repl_set_connection.rb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/mongo/repl_set_connection.rb b/lib/mongo/repl_set_connection.rb index 6a65324..8a00f87 100644 --- a/lib/mongo/repl_set_connection.rb +++ b/lib/mongo/repl_set_connection.rb @@ -308,7 +308,12 @@ module Mongo # Note that @read_pool might point to the primary pool # if no read pool has been defined. def checkout_reader - connect unless connected? + if connected? + sync_refresh + else + connect + end + begin socket = get_socket_from_pool(self.read_pool) @@ -330,7 +335,11 @@ module Mongo # Checkout a socket for writing (i.e., a primary node). def checkout_writer - connect unless connected? + if connected? + sync_refresh + else + connect + end begin socket = get_socket_from_pool(self.primary_pool)