RUBY-429 rescue and raise appropriate errors
This commit is contained in:
parent
92af319412
commit
76bf4dffe5
|
@ -45,7 +45,7 @@ module Mongo
|
||||||
else
|
else
|
||||||
socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
|
socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
|
||||||
end
|
end
|
||||||
rescue OperationTimeout, OperationFailure, SocketError, SystemCallError, IOError => ex
|
rescue OperationTimeout, ConnectionFailure, OperationFailure, SocketError, SystemCallError, IOError => ex
|
||||||
@connection.log(:debug, "Failed connection to #{host_string} with #{ex.class}, #{ex.message}.")
|
@connection.log(:debug, "Failed connection to #{host_string} with #{ex.class}, #{ex.message}.")
|
||||||
socket.close if socket
|
socket.close if socket
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -60,8 +60,14 @@ module Mongo
|
||||||
|
|
||||||
def read(maxlen, buffer)
|
def read(maxlen, buffer)
|
||||||
# Block on data to read for @op_timeout seconds
|
# Block on data to read for @op_timeout seconds
|
||||||
if IO.select([@socket], nil, nil, @op_timeout)
|
if IO.select([@socket], nil, [@socket], @op_timeout)
|
||||||
@socket.readpartial(maxlen, buffer)
|
begin
|
||||||
|
@socket.readpartial(maxlen, buffer)
|
||||||
|
rescue EOFError
|
||||||
|
return ConnectionError
|
||||||
|
rescue Errno::ECONNRESET
|
||||||
|
raise ConnectionFailure
|
||||||
|
end
|
||||||
else
|
else
|
||||||
raise OperationTimeout
|
raise OperationTimeout
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue