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] = {}
end
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
end
@ -328,6 +333,10 @@ module Mongo
self.connections[self.object_id] = {}
end
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
end

View File

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

View File

@ -257,7 +257,9 @@ module Mongo
def get_valid_seed_node
@seeds.each do |seed|
node = Mongo::Node.new(self.connection, seed)
if node.connect && node.set_config
if !node.connect
next
elsif node.set_config
return node
else
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]],
[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.secondaries.length

View File

@ -93,8 +93,14 @@ class Test::Unit::TestCase
begin
yield
rescue => e
assert_equal klass, e.class
assert e.message.include?(message), "#{e.message} does not include #{message}."
if klass.to_s != e.class.to_s
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
flunk "Expected assertion #{klass} but none was raised."
end