# File lib/mongo/util/pool.rb, line 191 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_local[:sockets][self.object_id] = socket socket end