diff options
author | Jan Alexander Steffens (heftig) <heftig@archlinux.org> | 2023-03-24 01:48:04 +0100 |
---|---|---|
committer | Frank Ch. Eigler <fche@redhat.com> | 2023-03-30 14:56:22 -0400 |
commit | 1b4cf71db1f72c53ff34c0e5c4a9da67dc24fdd6 (patch) | |
tree | 9a3685f5ce4043faefbc409ef16a69f52dee2736 | |
parent | 75800e911b73804cb3354edcc1ba9de3adaefa4e (diff) | |
download | elfutils-1b4cf71db1f72c53ff34c0e5c4a9da67dc24fdd6.tar.gz |
debuginfod: Don't touch access time of new files
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>
-rw-r--r-- | debuginfod/ChangeLog | 6 | ||||
-rw-r--r-- | debuginfod/debuginfod-client.c | 16 | ||||
-rw-r--r-- | debuginfod/debuginfod.cxx | 10 |
3 files changed, 22 insertions, 10 deletions
diff --git a/debuginfod/ChangeLog b/debuginfod/ChangeLog index c8de6ca0..c8c56232 100644 --- a/debuginfod/ChangeLog +++ b/debuginfod/ChangeLog @@ -1,3 +1,9 @@ +2023-03-30 Jan Alexander Steffens (heftig) <heftig@archlinux.org> + + * debuginfod-client.c (debuginfod_query_server): Don't modify + atime unintentionally. + * debuginfod.cxx (extract_section, handle_buildid_r_match): Ditto. + 2023-03-30 Aaron Merey <amerey@redhat.com> * debuginfod-client.c (debuginfod_query_server): Avoid sscanf on diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c index 5dfc8e62..7d0b153e 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 |