Ensure we pass pool timeout to pool.
This commit is contained in:
parent
d171f75bb0
commit
f98c1099dc
@ -37,7 +37,8 @@ module Mongo
|
|||||||
RESPONSE_HEADER_SIZE = 20
|
RESPONSE_HEADER_SIZE = 20
|
||||||
|
|
||||||
attr_reader :logger, :size, :auths, :primary, :safe, :host_to_try,
|
attr_reader :logger, :size, :auths, :primary, :safe, :host_to_try,
|
||||||
:pool_size, :connect_timeout, :primary_pool, :socket_class
|
:pool_size, :connect_timeout, :pool_timeout,
|
||||||
|
:primary_pool, :socket_class
|
||||||
|
|
||||||
# Counter for generating unique request ids.
|
# Counter for generating unique request ids.
|
||||||
@@current_request_id = 0
|
@@current_request_id = 0
|
||||||
@ -670,7 +671,7 @@ module Mongo
|
|||||||
warn "The :timeout option has been deprecated " +
|
warn "The :timeout option has been deprecated " +
|
||||||
"and will be removed in the 2.0 release. Use :pool_timeout instead."
|
"and will be removed in the 2.0 release. Use :pool_timeout instead."
|
||||||
end
|
end
|
||||||
@timeout = opts[:pool_timeout] || opts[:timeout] || 5.0
|
@pool_timeout = opts[:pool_timeout] || opts[:timeout] || 5.0
|
||||||
|
|
||||||
# Timeout on socket read operation.
|
# Timeout on socket read operation.
|
||||||
@op_timeout = opts[:op_timeout] || nil
|
@op_timeout = opts[:op_timeout] || nil
|
||||||
@ -758,7 +759,7 @@ module Mongo
|
|||||||
def set_primary(node)
|
def set_primary(node)
|
||||||
host, port = *node
|
host, port = *node
|
||||||
@primary = [host, port]
|
@primary = [host, port]
|
||||||
@primary_pool = Pool.new(self, host, port, :size => @pool_size, :timeout => @timeout)
|
@primary_pool = Pool.new(self, host, port, :size => @pool_size, :timeout => @pool_timeout)
|
||||||
end
|
end
|
||||||
|
|
||||||
## Low-level connection methods.
|
## Low-level connection methods.
|
||||||
|
@ -36,6 +36,7 @@ module Mongo
|
|||||||
def connect
|
def connect
|
||||||
begin
|
begin
|
||||||
socket = nil
|
socket = nil
|
||||||
|
puts "Creating connection in node to #{@host}:#{@port}"
|
||||||
if @connection.connect_timeout
|
if @connection.connect_timeout
|
||||||
Mongo::TimeoutHandler.timeout(@connection.connect_timeout, OperationTimeout) do
|
Mongo::TimeoutHandler.timeout(@connection.connect_timeout, OperationTimeout) do
|
||||||
socket = @connection.socket_class.new(@host, @port)
|
socket = @connection.socket_class.new(@host, @port)
|
||||||
|
@ -150,6 +150,7 @@ module Mongo
|
|||||||
# therefore, it runs within a mutex.
|
# therefore, it runs within a mutex.
|
||||||
def checkout_new_socket
|
def checkout_new_socket
|
||||||
begin
|
begin
|
||||||
|
puts "Creating connection in pool to #{@host}:#{@port}"
|
||||||
socket = self.connection.socket_class.new(@host, @port)
|
socket = self.connection.socket_class.new(@host, @port)
|
||||||
socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
|
socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
|
||||||
rescue => ex
|
rescue => ex
|
||||||
|
@ -188,7 +188,7 @@ module Mongo
|
|||||||
@primary = member.host_port
|
@primary = member.host_port
|
||||||
@primary_pool = Pool.new(self.connection, member.host, member.port,
|
@primary_pool = Pool.new(self.connection, member.host, member.port,
|
||||||
:size => self.connection.pool_size,
|
:size => self.connection.pool_size,
|
||||||
:timeout => self.connection.connect_timeout,
|
:timeout => self.connection.pool_timeout,
|
||||||
:node => member)
|
:node => member)
|
||||||
associate_tags_with_pool(member.tags, @primary_pool)
|
associate_tags_with_pool(member.tags, @primary_pool)
|
||||||
end
|
end
|
||||||
@ -198,7 +198,7 @@ module Mongo
|
|||||||
@secondaries << member.host_port
|
@secondaries << member.host_port
|
||||||
pool = Pool.new(self.connection, member.host, member.port,
|
pool = Pool.new(self.connection, member.host, member.port,
|
||||||
:size => self.connection.pool_size,
|
:size => self.connection.pool_size,
|
||||||
:timeout => self.connection.connect_timeout,
|
:timeout => self.connection.pool_timeout,
|
||||||
:node => member)
|
:node => member)
|
||||||
@secondary_pools << pool
|
@secondary_pools << pool
|
||||||
associate_tags_with_pool(member.tags, pool)
|
associate_tags_with_pool(member.tags, pool)
|
||||||
|
Loading…
Reference in New Issue
Block a user