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