# File lib/mongo/util/pool.rb, line 181 def checkout_new_socket begin socket = @client.socket_class.new(@host, @port, @client.op_timeout) socket.pool = self rescue => ex socket.close if socket raise ConnectionFailure, "Failed to connect to host #{@host} and port #{@port}: #{ex}" @node.close if @node end # If any saved authentications exist, we want to apply those # when creating new sockets. @client.apply_saved_authentication(:socket => socket) @sockets << socket @checked_out << socket @thread_ids_to_sockets[Thread.current.object_id] = socket socket end