RUBY-429 wrap IO errors from select and read
This commit is contained in:
parent
dfca0dd134
commit
0bd7d3830d
|
@ -60,14 +60,19 @@ 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, [@socket], @op_timeout)
|
begin
|
||||||
|
ready = IO.select([@socket], nil, [@socket], @op_timeout)
|
||||||
|
rescue IOError
|
||||||
|
raise OperationFailure
|
||||||
|
end
|
||||||
|
if ready
|
||||||
begin
|
begin
|
||||||
@socket.readpartial(maxlen, buffer)
|
@socket.readpartial(maxlen, buffer)
|
||||||
rescue EOFError
|
rescue EOFError
|
||||||
return ConnectionError
|
return ConnectionError
|
||||||
rescue Errno::ENOTCONN, Errno::EBADF, Errno::ECONNRESET, Errno::EPIPE
|
rescue Errno::ENOTCONN, Errno::EBADF, Errno::ECONNRESET, Errno::EPIPE
|
||||||
raise ConnectionFailure
|
raise ConnectionFailure
|
||||||
rescue Errno::EINTR, Errno::EIO
|
rescue Errno::EINTR, Errno::EIO, IOError
|
||||||
raise OperationFailure
|
raise OperationFailure
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue