minor: text fixes

This commit is contained in:
Kyle Banker 2011-11-07 13:36:57 -05:00
parent 9cb9f5c663
commit fbdf16bd48
5 changed files with 23 additions and 7 deletions

View File

@ -317,6 +317,11 @@ module Mongo
self.connections[self.object_id] = {} self.connections[self.object_id] = {}
end end
socket = self.connections[self.object_id][:reader] ||= checkout_reader socket = self.connections[self.object_id][:reader] ||= checkout_reader
if self.read_pool != @sockets_to_pools[socket]
checkin(socket)
socket = self.connections[self.object_id][:reader] = checkout_reader
end
@threads_to_sockets[Thread.current][:reader] = socket @threads_to_sockets[Thread.current][:reader] = socket
end end
@ -328,6 +333,10 @@ module Mongo
self.connections[self.object_id] = {} self.connections[self.object_id] = {}
end end
socket = self.connections[self.object_id][:writer] ||= checkout_writer socket = self.connections[self.object_id][:writer] ||= checkout_writer
if self.primary_pool != @sockets_to_pools[socket]
checkin(socket)
socket = self.connections[self.object_id][:writer] = checkout_writer
end
@threads_to_sockets[Thread.current][:writer] = socket @threads_to_sockets[Thread.current][:writer] = socket
end end

View File

@ -60,11 +60,11 @@ module Mongo
end end
def close def close
if @socket if @socket && !@socket.closed?
@socket.close @socket.close
@socket = nil
@config = nil
end end
@socket = nil
@config = nil
end end
def connected? def connected?

View File

@ -257,7 +257,9 @@ module Mongo
def get_valid_seed_node def get_valid_seed_node
@seeds.each do |seed| @seeds.each do |seed|
node = Mongo::Node.new(self.connection, seed) node = Mongo::Node.new(self.connection, seed)
if node.connect && node.set_config if !node.connect
next
elsif node.set_config
return node return node
else else
node.close node.close

View File

@ -87,7 +87,6 @@ class ReplicaSetRefreshTest < Test::Unit::TestCase
@conn = ReplSetConnection.new([self.rs.host, self.rs.ports[0]], [self.rs.host, self.rs.ports[1]], @conn = ReplSetConnection.new([self.rs.host, self.rs.ports[0]], [self.rs.host, self.rs.ports[1]],
[self.rs.host, self.rs.ports[2]], :refresh_interval => 2, :refresh_mode => :async) [self.rs.host, self.rs.ports[2]], :refresh_interval => 2, :refresh_mode => :async)
@conn.secondary_pools
assert_equal 2, @conn.secondary_pools.length assert_equal 2, @conn.secondary_pools.length
assert_equal 2, @conn.secondaries.length assert_equal 2, @conn.secondaries.length

View File

@ -93,8 +93,14 @@ class Test::Unit::TestCase
begin begin
yield yield
rescue => e rescue => e
assert_equal klass, e.class if klass.to_s != e.class.to_s
assert e.message.include?(message), "#{e.message} does not include #{message}." flunk "Expected exception class #{klass} but got #{e.class}.\n #{e.backtrace}"
end
if !e.message.include?(message)
p e.backtrace
flunk "#{e.message} does not include #{message}.\n#{e.backtrace}"
end
else else
flunk "Expected assertion #{klass} but none was raised." flunk "Expected assertion #{klass} but none was raised."
end end