From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 75C0D3858D29 for ; Mon, 10 Jun 2024 09:57:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 75C0D3858D29 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 75C0D3858D29 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718013432; cv=none; b=vSABbK8k7nAgYKK97oHE8rc72lnZPlAygEu5I9I3qUb0rF98jxqMu4uPY2yoiwor9qBUySy9lUCwyfqFJpdkr9fzQ1W8aeyS+9BTCwlxEA0u6sCWLXrOkihMkF4nNg5CcpCCYSLOKVVUYBjQN/E9SkewJqtyVD2xEycTn5J05sE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718013432; c=relaxed/simple; bh=/Qwl43taHNUfXQw2Whl82Lx8uLRRtQrjjffp47sGGNY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=kuL8yeJdfZoQ1Nzjpl+Y82P2Jt8Z1AGIycuz8xnBkKxFCjnMMlbbxiy1fsRZJy3cc2lw5k+UenmgF6WNcrFkYhuP9QfIZTmCCt9l/YoCDqDvEFIAR9KEWeYXFC6o5wnGKdO8U6IkwBqPmMGrDx/l5ZMsakbyo4IZE8qED7CQpDQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718013430; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=PTeMS3pqpoKZJrJO8ajlRHDlVfN/2ibHbE4265QVhwo=; b=D+jsPxL/L+SYE/oVp22UZQn2K/r1/UyycScv58/1R1cnyiDJ74sfKCKAAskgWSI/0j2Y8H as6JPg27uy3XSZ4r/vSn2v1fneiMbB50/qlushoZ4OzgnZnr255tOEu3usYuCXQvo8yrJp UyBuyvPFAycjLBWa6FwL7I5374lAsoc= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-349-u4hW3zN3Pl2BKB5Z0CZhjw-1; Mon, 10 Jun 2024 05:57:06 -0400 X-MC-Unique: u4hW3zN3Pl2BKB5Z0CZhjw-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7B2F21956067; Mon, 10 Jun 2024 09:57:05 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.193.168]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 56CD130000C4; Mon, 10 Jun 2024 09:57:04 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org Cc: levon@movementarian.org Subject: [PATCH] resolv: Track single-request fallback via _res._flags (bug 31476) Date: Mon, 10 Jun 2024 11:57:01 +0200 Message-ID: <87ikyhqfwy.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This avoids changing _res.options, which inteferes with change detection as part of automatic reloading of /etc/resolv.conf. Tested on x86_64-linux-gnu with the existing tests. Not sure how to write a good regression test for this. --- resolv/res_send.c | 12 +++++++----- resolv/resolv-internal.h | 2 ++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/resolv/res_send.c b/resolv/res_send.c index fb0217204a..ea7cf192b2 100644 --- a/resolv/res_send.c +++ b/resolv/res_send.c @@ -947,9 +947,11 @@ send_dg(res_state statp, seconds /= statp->nscount; if (seconds <= 0) seconds = 1; - bool single_request_reopen = (statp->options & RES_SNGLKUPREOP) != 0; - bool single_request = (((statp->options & RES_SNGLKUP) != 0) - | single_request_reopen); + bool single_request_reopen = ((statp->options & RES_SNGLKUPREOP) + || (statp->_flags & RES_F_SNGLKUPREOP)); + bool single_request = ((statp->options & RES_SNGLKUP) + || (statp->_flags & RES_F_SNGLKUP) + || single_request_reopen); int save_gotsomewhere = *gotsomewhere; int retval; @@ -1006,14 +1008,14 @@ send_dg(res_state statp, have received the first answer. */ if (!single_request) { - statp->options |= RES_SNGLKUP; + statp->_flags |= RES_F_SNGLKUP; single_request = true; *gotsomewhere = save_gotsomewhere; goto retry; } else if (!single_request_reopen) { - statp->options |= RES_SNGLKUPREOP; + statp->_flags |= RES_F_SNGLKUPREOP; single_request_reopen = true; *gotsomewhere = save_gotsomewhere; __res_iclose (statp, false); diff --git a/resolv/resolv-internal.h b/resolv/resolv-internal.h index 24b164f6b5..944af3ee76 100644 --- a/resolv/resolv-internal.h +++ b/resolv/resolv-internal.h @@ -26,6 +26,8 @@ #define RES_F_VC 0x00000001 /* Socket is TCP. */ #define RES_F_CONN 0x00000002 /* Socket is connected. */ #define RES_F_EDNS0ERR 0x00000004 /* EDNS0 caused errors. */ +#define RES_F_SNGLKUP 0x00200000 /* Private version of RES_SNGLKUP. */ +#define RES_F_SNGLKUPREOP 0x00400000 /* Private version of RES_SNGLKUPREOP. */ /* The structure HEADER is normally aligned on a word boundary. In some code, we need to access this structure when it may be aligned base-commit: 54c1efdac55b756a4e2ea95590bcc3ba396a6568