From: "Jan Alexander Steffens (heftig)" <heftig@archlinux.org>
To: elfutils-devel@sourceware.org
Cc: "Jan Alexander Steffens (heftig)" <heftig@archlinux.org>
Subject: [PATCH 2/3] debuginfod: Don't touch access time of new files
Date: Fri, 24 Mar 2023 01:48:04 +0100 [thread overview]
Message-ID: <20230324004805.156080-2-heftig@archlinux.org> (raw)
In-Reply-To: <20230324004805.156080-1-heftig@archlinux.org>
Instead of copying the mtime, which might be far in the past, don't
touch the access time. This will prevent cache cleaning from considering
the file as old immediately.
Signed-off-by: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
---
debuginfod/debuginfod-client.c | 16 +++++++++-------
debuginfod/debuginfod.cxx | 10 +++++++---
2 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c
index 460afd5c..1a2d7573 100644
--- a/debuginfod/debuginfod-client.c
+++ b/debuginfod/debuginfod-client.c
@@ -1718,13 +1718,15 @@ debuginfod_query_server (debuginfod_client *c,
#else
CURLcode curl_res = curl_easy_getinfo(verified_handle, CURLINFO_FILETIME, (void*) &mtime);
#endif
- if (curl_res != CURLE_OK)
- mtime = time(NULL); /* fall back to current time */
-
- struct timespec tvs[2];
- tvs[0].tv_sec = tvs[1].tv_sec = mtime;
- tvs[0].tv_nsec = tvs[1].tv_nsec = 0;
- (void) futimens (fd, tvs); /* best effort */
+ if (curl_res == CURLE_OK)
+ {
+ struct timespec tvs[2];
+ tvs[0].tv_sec = 0;
+ tvs[0].tv_nsec = UTIME_OMIT;
+ tvs[1].tv_sec = mtime;
+ tvs[1].tv_nsec = 0;
+ (void) futimens (fd, tvs); /* best effort */
+ }
/* PR27571: make cache files casually unwriteable; dirs are already 0700 */
(void) fchmod(fd, 0400);
diff --git a/debuginfod/debuginfod.cxx b/debuginfod/debuginfod.cxx
index b39c0591..5ef6cc32 100644
--- a/debuginfod/debuginfod.cxx
+++ b/debuginfod/debuginfod.cxx
@@ -1639,7 +1639,9 @@ extract_section (int elf_fd, int64_t parent_mtime,
if (fstat (elf_fd, &fs) != 0)
throw libc_exception (errno, "cannot fstat file");
- tvs[0] = tvs[1] = fs.st_mtim;
+ tvs[0].tv_sec = 0;
+ tvs[0].tv_nsec = UTIME_OMIT;
+ tvs[1] = fs.st_mtim;
(void) futimens (fd, tvs);
/* Add to fdcache. */
@@ -1951,8 +1953,10 @@ handle_buildid_r_match (bool internal_req_p,
// Set the mtime so the fdcache file mtimes, even prefetched ones,
// propagate to future webapi clients.
struct timespec tvs[2];
- tvs[0].tv_sec = tvs[1].tv_sec = archive_entry_mtime(e);
- tvs[0].tv_nsec = tvs[1].tv_nsec = archive_entry_mtime_nsec(e);
+ tvs[0].tv_sec = 0;
+ tvs[0].tv_nsec = UTIME_OMIT;
+ tvs[1].tv_sec = archive_entry_mtime(e);
+ tvs[1].tv_nsec = archive_entry_mtime_nsec(e);
(void) futimens (fd, tvs); /* best effort */
if (r != 0) // stage 3
--
2.40.0
next prev parent reply other threads:[~2023-03-24 0:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-24 0:48 [PATCH 1/3] debuginfod: Replace futimes with futimens Jan Alexander Steffens (heftig)
2023-03-24 0:48 ` Jan Alexander Steffens (heftig) [this message]
2023-03-24 0:48 ` [PATCH 3/3] debuginfod: When retrieving files from cache, update atime manually Jan Alexander Steffens (heftig)
2023-03-29 20:54 ` Frank Ch. Eigler
2023-03-29 21:32 ` Jan Alexander Steffens (heftig)
2023-03-29 20:47 ` [PATCH 1/3] debuginfod: Replace futimes with futimens Frank Ch. Eigler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230324004805.156080-2-heftig@archlinux.org \
--to=heftig@archlinux.org \
--cc=elfutils-devel@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).