From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 80438 invoked by alias); 13 Feb 2020 20:53:42 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 80424 invoked by uid 89); 13 Feb 2020 20:53:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.0 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-qt1-f193.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:references:from:autocrypt:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=PkSANoDndv/JA9wpB25CckjI8ZzoxPfDnyP+FUQ4sqI=; b=iSii0N72VuqtGfjHVUygWdtE7J1JSJgj/PC+I+FON6LBG7w4RBTg4rnxAnaDHYUN9P XD+NVX/gA+pcywG0rXTHGwVLlnebwED8oJe/ymVD0OVizkTcvP8VVKm5gpsykYECpLGd YWzkIg0u57rJdp6MXFvYhYDfxMTeJ/7SZPf3LYxKlbEGzQqOJsc81yCoiQjw1I0rG502 euYJ/jj6gRuzQscW/fkHVtQOrnUmvatymbZo9VspJkHl6rv6TvBzCl7ypXCYqa7KmCg6 c+K6rWSc7M+LZWhYj47Pw+q5vz5pkCB+3ks3MuQ0WDPH6ZlAqB1l4gCMTNjH1kxofrOS PasA== Return-Path: Subject: Re: [PATCH 2/5] resolv: Use in __resolv_conf_get_current To: libc-alpha@sourceware.org References: From: Adhemerval Zanella Message-ID: <6bb92349-0f68-dc7b-0b57-1f68a028b55a@linaro.org> Date: Thu, 13 Feb 2020 20:53:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2020-02/txt/msg00619.txt.bz2 On 21/01/2020 15:41, Florian Weimer wrote: > Only minor functional changes (i.e., regarding the handling of > directories, which are now treated as empty files). LGTM, thanks. Reviewed-by: Adhemerval Zanella > --- > resolv/resolv_conf.c | 43 ++++++++----------------------------------- > 1 file changed, 8 insertions(+), 35 deletions(-) > > diff --git a/resolv/resolv_conf.c b/resolv/resolv_conf.c > index 08c50ef19e..d954ba9a5a 100644 > --- a/resolv/resolv_conf.c > +++ b/resolv/resolv_conf.c > @@ -24,6 +24,7 @@ > #include > #include > #include > +#include > > /* _res._u._ext.__glibc_extension_index is used as an index into a > struct resolv_conf_array object. The intent of this construction > @@ -68,12 +69,8 @@ struct resolv_conf_global > /* Cached current configuration object for /etc/resolv.conf. */ > struct resolv_conf *conf_current; > > - /* These properties of /etc/resolv.conf are used to check if the > - configuration needs reloading. */ > - struct timespec conf_mtime; > - struct timespec conf_ctime; > - off64_t conf_size; > - ino64_t conf_ino; > + /* File system identification for /etc/resolv.conf. */ > + struct file_change_detection file_resolve_conf; > }; > > /* Lazily allocated storage for struct resolv_conf_global. */ Ok. > @@ -123,37 +120,16 @@ conf_decrement (struct resolv_conf *conf) > struct resolv_conf * > __resolv_conf_get_current (void) > { > - struct stat64 st; > - if (stat64 (_PATH_RESCONF, &st) != 0) > - { > - switch (errno) > - { > - case EACCES: > - case EISDIR: > - case ELOOP: > - case ENOENT: > - case ENOTDIR: > - case EPERM: > - /* Ignore errors due to file system contents. */ > - memset (&st, 0, sizeof (st)); > - break; > - default: > - /* Other errors are fatal. */ > - return NULL; > - } > - } > + struct file_change_detection initial; > + if (!file_change_detection_for_path (&initial, _PATH_RESCONF)) > + return NULL; > Ok. > struct resolv_conf_global *global_copy = get_locked_global (); > if (global_copy == NULL) > return NULL; > struct resolv_conf *conf; > if (global_copy->conf_current != NULL > - && (global_copy->conf_mtime.tv_sec == st.st_mtim.tv_sec > - && global_copy->conf_mtime.tv_nsec == st.st_mtim.tv_nsec > - && global_copy->conf_ctime.tv_sec == st.st_ctim.tv_sec > - && global_copy->conf_ctime.tv_nsec == st.st_ctim.tv_nsec > - && global_copy->conf_ino == st.st_ino > - && global_copy->conf_size == st.st_size)) > + && file_is_unchanged (&initial, &global_copy->file_resolve_conf)) > /* We can reuse the cached configuration object. */ > conf = global_copy->conf_current; > else > @@ -171,10 +147,7 @@ __resolv_conf_get_current (void) > read could be a newer version of the file, but this does > not matter because this will lead to an extraneous reload > later. */ > - global_copy->conf_mtime = st.st_mtim; > - global_copy->conf_ctime = st.st_ctim; > - global_copy->conf_ino = st.st_ino; > - global_copy->conf_size = st.st_size; > + global_copy->file_resolve_conf = initial; > } > } > > Ok.