Distinguish between hard and soft pool close.
This commit is contained in:
parent
3e2c4c3851
commit
a2a307c45d
@ -496,10 +496,8 @@ module Mongo
|
|||||||
# Used to close, check in, or refresh sockets held
|
# Used to close, check in, or refresh sockets held
|
||||||
# in thread-local variables.
|
# in thread-local variables.
|
||||||
def local_socket_done(socket)
|
def local_socket_done(socket)
|
||||||
puts "Done. Threads: #{Thread.list.size}, pool_size: #{self.pool_size}"
|
|
||||||
if self.connections[self.object_id][:reader] == socket
|
if self.connections[self.object_id][:reader] == socket
|
||||||
if self.read_pool.sockets_low?
|
if self.read_pool.sockets_low?
|
||||||
puts "***SOCKETS ARE LOW! READER****"
|
|
||||||
checkin(socket)
|
checkin(socket)
|
||||||
self.connections[self.object_id][:reader] = nil
|
self.connections[self.object_id][:reader] = nil
|
||||||
end
|
end
|
||||||
@ -507,7 +505,6 @@ module Mongo
|
|||||||
|
|
||||||
if self.connections[self.object_id][:writer] == socket
|
if self.connections[self.object_id][:writer] == socket
|
||||||
if self.primary_pool && self.primary_pool.sockets_low?
|
if self.primary_pool && self.primary_pool.sockets_low?
|
||||||
puts "***SOCKETS ARE LOW! WRITER****"
|
|
||||||
checkin(socket)
|
checkin(socket)
|
||||||
self.connections[self.object_id][:writer] = nil
|
self.connections[self.object_id][:writer] = nil
|
||||||
end
|
end
|
||||||
|
@ -207,7 +207,9 @@ module Mongo
|
|||||||
background_manager.connect
|
background_manager.connect
|
||||||
|
|
||||||
# TODO: make sure that connect has succeeded
|
# TODO: make sure that connect has succeeded
|
||||||
|
old_manager = @manager
|
||||||
update_config(background_manager)
|
update_config(background_manager)
|
||||||
|
old_manager.close(:soft => true)
|
||||||
initiate_refresh_mode
|
initiate_refresh_mode
|
||||||
|
|
||||||
return true
|
return true
|
||||||
@ -516,7 +518,6 @@ module Mongo
|
|||||||
@seeds = @manager.seeds.dup
|
@seeds = @manager.seeds.dup
|
||||||
@sockets_to_pools.clear
|
@sockets_to_pools.clear
|
||||||
@refresh_version += 1
|
@refresh_version += 1
|
||||||
old_manager.close if old_manager
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# If we're using async refresh, start
|
# If we're using async refresh, start
|
||||||
|
@ -59,9 +59,18 @@ module Mongo
|
|||||||
@closed = false
|
@closed = false
|
||||||
end
|
end
|
||||||
|
|
||||||
def close
|
# Close this pool.
|
||||||
|
#
|
||||||
|
# @option opts [Boolean] :soft (false) If true,
|
||||||
|
# close only those sockets that are not checked out.
|
||||||
|
def close(opts={})
|
||||||
@connection_mutex.synchronize do
|
@connection_mutex.synchronize do
|
||||||
(@sockets - @checked_out).each do |sock|
|
if opts[:soft]
|
||||||
|
sockets_to_close = @sockets - @checked_out
|
||||||
|
else
|
||||||
|
sockets_to_close = @sockets
|
||||||
|
end
|
||||||
|
sockets_to_close.each do |sock|
|
||||||
begin
|
begin
|
||||||
sock.close
|
sock.close
|
||||||
rescue IOError => ex
|
rescue IOError => ex
|
||||||
|
Loading…
Reference in New Issue
Block a user