Skip to content

Commit 6dd7f96

Browse files
committed
Merge pull request #650 from estolfo/RUBY-901-handle-socket-errors
RUBY-901 Handle errors when connecting in socket classes
2 parents 03e4a29 + ce8bfac commit 6dd7f96

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

lib/mongo/socket/ssl.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ class SSL < Socket
5454
# @since 2.0.0
5555
def connect!
5656
Timeout.timeout(timeout, Error::SocketTimeoutError) do
57-
@tcp_socket.connect(::Socket.pack_sockaddr_in(port, host))
57+
handle_errors { @tcp_socket.connect(::Socket.pack_sockaddr_in(port, host)) }
5858
@socket = OpenSSL::SSL::SSLSocket.new(@tcp_socket, context)
5959
@socket.sync_close = true
60-
@socket.connect
60+
handle_errors { @socket.connect }
6161
verify_certificate!(@socket)
6262
self
6363
end

lib/mongo/socket/tcp.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class TCP < Socket
4343
def connect!
4444
Timeout.timeout(timeout, Error::SocketTimeoutError) do
4545
socket.setsockopt(IPPROTO_TCP, TCP_NODELAY, 1)
46-
socket.connect(::Socket.pack_sockaddr_in(port, host))
46+
handle_errors { socket.connect(::Socket.pack_sockaddr_in(port, host)) }
4747
self
4848
end
4949
end

lib/mongo/socket/unix.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Unix < Socket
3939
# @since 2.0.0
4040
def connect!
4141
Timeout.timeout(timeout, Error::SocketTimeoutError) do
42-
socket.connect(path)
42+
handle_errors { socket.connect(path) }
4343
self
4444
end
4545
end

0 commit comments

Comments
 (0)