From patchwork Tue Jun 3 23:36:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Jarno X-Patchwork-Id: 355674 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 DBF831400DD for ; Wed, 4 Jun 2014 09:37:30 +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=mPGc8/d95KjvaZsjYX7u9Q4oBrRsiYt cswJNO6LIolZOMqVJuOb/5d2l7LBJ4AUbHzAR6mdZ/MW1g51aWh1nSTfbx3FfzPT 2F6MAYa8+f1oyGI8r42bl3I3R5srYYoHKLZldvdpVXbtRC4kCSdTURpXrWfBcnOw nqh1vVnAbS7s= 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=tsRAYnY3CKFTN8zaMxZBBtTMwlQ=; b=Bc9Ma Vl5ktsEj9R3XWfHFaIRiYSba9TqEnbb7o0QJ+hJR3ZzWWVAt2EV0eVjM31ggcrI2 dJ/u4Cg5tVxoIBOT37DmWSHD6kNb5fN6QBy66DP006jNEoaRL58fISdhpJxRp0hD zFuLAbNDDDixZG/CsGzoJQHzri2UQMjGQzYGGo= Received: (qmail 10163 invoked by alias); 3 Jun 2014 23:36:55 -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 10003 invoked by uid 89); 3 Jun 2014 23:36:54 -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: [RFC PATCH 4/4] resolv: fix rotate option Date: Wed, 4 Jun 2014 01:36:43 +0200 Message-Id: <1401838603-22101-5-git-send-email-aurelien@aurel32.net> In-Reply-To: <1401838603-22101-1-git-send-email-aurelien@aurel32.net> References: <1401838603-22101-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 nameserver 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. --- resolv/res_init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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)