Skip to content

RUBY-901 Handle errors when connecting in socket classes #650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 6, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/mongo/socket/ssl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ class SSL < Socket
# @since 2.0.0
def connect!
Timeout.timeout(timeout, Error::SocketTimeoutError) do
@tcp_socket.connect(::Socket.pack_sockaddr_in(port, host))
handle_errors { @tcp_socket.connect(::Socket.pack_sockaddr_in(port, host)) }
@socket = OpenSSL::SSL::SSLSocket.new(@tcp_socket, context)
@socket.sync_close = true
@socket.connect
handle_errors { @socket.connect }
verify_certificate!(@socket)
self
end
Expand Down
2 changes: 1 addition & 1 deletion lib/mongo/socket/tcp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class TCP < Socket
def connect!
Timeout.timeout(timeout, Error::SocketTimeoutError) do
socket.setsockopt(IPPROTO_TCP, TCP_NODELAY, 1)
socket.connect(::Socket.pack_sockaddr_in(port, host))
handle_errors { socket.connect(::Socket.pack_sockaddr_in(port, host)) }
self
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/mongo/socket/unix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Unix < Socket
# @since 2.0.0
def connect!
Timeout.timeout(timeout, Error::SocketTimeoutError) do
socket.connect(path)
handle_errors { socket.connect(path) }
self
end
end
Expand Down