minor: refactor TCP_NODELAY
This commit is contained in:
parent
95a831c0b3
commit
00cea59c10
@ -623,8 +623,6 @@ module Mongo
|
||||
config = nil
|
||||
|
||||
socket = @socket_class.new(host, port, @op_timeout, @connect_timeout)
|
||||
socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
|
||||
|
||||
config = self['admin'].command({:ismaster => 1}, :socket => socket)
|
||||
rescue OperationFailure, SocketError, SystemCallError, IOError
|
||||
close
|
||||
|
@ -40,11 +40,7 @@ module Mongo
|
||||
@connection.op_timeout, @connection.connect_timeout
|
||||
)
|
||||
|
||||
if socket.nil?
|
||||
return nil
|
||||
else
|
||||
socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
|
||||
end
|
||||
return nil if socket.nil?
|
||||
rescue OperationTimeout, ConnectionFailure, OperationFailure, SocketError, SystemCallError, IOError => ex
|
||||
@connection.log(:debug, "Failed connection to #{host_string} with #{ex.class}, #{ex.message}.")
|
||||
socket.close if socket
|
||||
|
@ -157,7 +157,6 @@ module Mongo
|
||||
def checkout_new_socket
|
||||
begin
|
||||
socket = @connection.socket_class.new(@host, @port, @connection.op_timeout)
|
||||
socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
|
||||
socket.pool = self
|
||||
rescue => ex
|
||||
socket.close if socket
|
||||
|
@ -16,6 +16,8 @@ module Mongo
|
||||
@connect_timeout = connect_timeout
|
||||
|
||||
@socket = ::TCPSocket.new(host, port)
|
||||
@socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
|
||||
|
||||
@ssl = OpenSSL::SSL::SSLSocket.new(@socket)
|
||||
@ssl.sync_close = true
|
||||
|
||||
|
@ -16,8 +16,10 @@ module Mongo
|
||||
# TODO: Prefer ipv6 if server is ipv6 enabled
|
||||
@host = Socket.getaddrinfo(host, nil, Socket::AF_INET).first[3]
|
||||
@port = port
|
||||
|
||||
@socket_address = Socket.pack_sockaddr_in(@port, @host)
|
||||
@socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
|
||||
@socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
|
||||
|
||||
connect
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user