From patchwork Fri Jun 13 15:32:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Jarno X-Patchwork-Id: 359565 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 073D814009E for ; Sat, 14 Jun 2014 01:59:50 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=RrI1oX4MSIv8YyqGPoPRRdE4Jat8Ify U+h7PbsshQbTRtHcrkMXT1kv++UKrqBSB6AYqgZ0+CA7oljwwdOtBFahDnmennKq dryWpZiRbMkZmMNPbcpvvzgKczBnm0025v3g0jj+5cK9QVWZg5vMltE2XD0HL6l4 JJ4wUbEZRcPE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=1yrlKJgEFKEB/7rVj620GliFZtc=; b=pFQlU BSxcSpGN0k3k9Cb7LPZks6s0bquVbj02z7MG6hHG7ydg4xnIn1E5GN/vplOreZGH XwNJbLyo9UjQOVSA2qTE/OBU3YxedWfgre5Zc9bMeyX9cRAHcTK00lreyei70LSO LnnNLryCH/KYwYVbKgR4rnrdTBOFCdbHRzDBzg= Received: (qmail 30147 invoked by alias); 13 Jun 2014 15:59:45 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 30138 invoked by uid 89); 13 Jun 2014 15:59:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: hall.aurel32.net From: Aurelien Jarno To: libc-alpha@sourceware.org Cc: Aurelien Jarno Subject: [PATCH 4/4] resolv: fix rotate option Date: Fri, 13 Jun 2014 17:32:13 +0200 Message-Id: <1402673533-13243-5-git-send-email-aurelien@aurel32.net> In-Reply-To: <1402673533-13243-1-git-send-email-aurelien@aurel32.net> References: <1402673533-13243-1-git-send-email-aurelien@aurel32.net> The rotate option doesn't work correctly, and only send the query to the same server (the second in the list). The rotation code in itself is not broken, but the nsaddrs structure is reinitialized each time at the beginning of __libc_res_nsend unless RES_STAYOPEN is enabled. This is due to a call to __res_iclose from the end of __libc_res_nsend when answers from the name server have been received. This function closes all the sockets, but doesn't free the addresses (it can do that, but in that case the second argument is false). This patch change the code of __res_iclose to clear statp->_u._ext.nsinit only when the addresses are actually freed. 2014-06-13 Aurelien Jarno * resolv/res_init.c (__res_iclose): Only clear nsinit if the addresses have been freed. diff --git a/resolv/res_init.c b/resolv/res_init.c index 95564af..42e16b6 100644 --- a/resolv/res_init.c +++ b/resolv/res_init.c @@ -621,7 +621,8 @@ __res_iclose(res_state statp, bool free_addr) { statp->_u._ext.nsaddrs[ns] = NULL; } } - statp->_u._ext.nsinit = 0; + if (free_addr) + statp->_u._ext.nsinit = 0; } libc_hidden_def (__res_iclose)