Skip to content

Commit

Permalink
Move connection cleanup logic into the close method
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Bopp committed Oct 26, 2015
1 parent ab320af commit e829069
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/net/ldap/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,12 @@ def open_connection(server)
errors = []
hosts.each do |host, port|
begin
socket = TCPSocket.new(host, port)
prepare_socket(server.merge(socket: socket))
prepare_socket(server.merge(socket: TCPSocket.new(host, port)))
return
rescue Net::LDAP::Error, SocketError, SystemCallError,
OpenSSL::SSL::SSLError => e
# Ensure the connection is closed in the event a setup failure.
socket.close unless socket.nil?
socket = nil
close
errors << [e, host, port]
end
end
Expand Down Expand Up @@ -145,6 +143,7 @@ def setup_encryption(args)
# have to call it, but perhaps it will come in handy someday.
#++
def close
return if @conn.nil?
@conn.close
@conn = nil
end
Expand Down

0 comments on commit e829069

Please sign in to comment.