RUBY-441
Remove connect_nonblock from tcp_socket implementation to reduce problems due to inconsistent implementation in JRuby and Windows. Connection timeouts are now reverted to using the timeout module for all platforms.
This commit is contained in:
parent
b23be322c0
commit
65a1ecc42d
@ -1,4 +1,5 @@
|
|||||||
require 'socket'
|
require 'socket'
|
||||||
|
require 'timeout'
|
||||||
|
|
||||||
module Mongo
|
module Mongo
|
||||||
# Wrapper class for Socket
|
# Wrapper class for Socket
|
||||||
@ -25,9 +26,6 @@ module Mongo
|
|||||||
end
|
end
|
||||||
|
|
||||||
def connect
|
def connect
|
||||||
# Connect nonblock is broken in current versions of JRuby
|
|
||||||
if RUBY_PLATFORM == 'java'
|
|
||||||
require 'timeout'
|
|
||||||
if @connect_timeout
|
if @connect_timeout
|
||||||
Timeout::timeout(@connect_timeout, OperationTimeout) do
|
Timeout::timeout(@connect_timeout, OperationTimeout) do
|
||||||
@socket.connect(@socket_address)
|
@socket.connect(@socket_address)
|
||||||
@ -35,25 +33,6 @@ module Mongo
|
|||||||
else
|
else
|
||||||
@socket.connect(@socket_address)
|
@socket.connect(@socket_address)
|
||||||
end
|
end
|
||||||
else
|
|
||||||
# Try to connect for @connect_timeout seconds
|
|
||||||
begin
|
|
||||||
@socket.connect_nonblock(@socket_address)
|
|
||||||
rescue Errno::EINPROGRESS
|
|
||||||
# Block until there is a response or error
|
|
||||||
resp = IO.select([@socket], [@socket], [@socket], @connect_timeout)
|
|
||||||
if resp.nil?
|
|
||||||
raise ConnectionTimeoutError
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# If there was a failure this will raise an Error
|
|
||||||
begin
|
|
||||||
@socket.connect_nonblock(@socket_address)
|
|
||||||
rescue Errno::EISCONN
|
|
||||||
# Successfully connected
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def send(data)
|
def send(data)
|
||||||
|
Loading…
Reference in New Issue
Block a user