]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
debuginfod: update mtime of interval_path as early as possible
authorMark Wielaard <mark@klomp.org>
Sun, 8 May 2022 19:16:10 +0000 (21:16 +0200)
committerMark Wielaard <mark@klomp.org>
Sat, 14 May 2022 22:26:31 +0000 (00:26 +0200)
Call utime on interval_path file as soon as the thread is committed to
cleanup the cache files. This will prevent other threads trying to
also commit to cleaning the cache files. Having multiple threads try
to clean the cache simultaniously doesn't improve cleanup speed
because the threads will try to delete the files in the same order.

Signed-off-by: Mark Wielaard <mark@klomp.org>
debuginfod/ChangeLog
debuginfod/debuginfod-client.c

index 93aaedb6290cf7dd787f572c760ea76c716e4e6e..8c54ec215ae2cd6540b1929dd4a323526bb01456 100644 (file)
@@ -1,3 +1,8 @@
+2022-05-09  Mark Wielaard  <mark@klomp.org>
+
+       * debuginfod-client.c (debuginfod_clean_cache): Move utime call to
+       before fts traversal.
+
 2022-05-09  Mark Wielaard  <mark@klomp.org>
 
        * debuginfod-client.c (debuginfod_init_cache): Remove.
index 6bdf19082fb61ae632e5b60570091fe68ca2b202..b7b65affe7553d10ce7ccd3a788710c431696e83 100644 (file)
@@ -297,6 +297,11 @@ debuginfod_clean_cache(debuginfod_client *c,
     /* Interval has not passed, skip cleaning.  */
     return 0;
 
+  /* Update timestamp representing when the cache was last cleaned.
+     Do it at the start to reduce the number of threads trying to do a
+     cleanup simultaniously.  */
+  utime (interval_path, NULL);
+
   /* Read max unused age value from config file.  */
   rc = debuginfod_config_cache(max_unused_path,
                               cache_default_max_unused_age_s, &st);
@@ -351,8 +356,6 @@ debuginfod_clean_cache(debuginfod_client *c,
   fts_close (fts);
   regfree (&re);
 
-  /* Update timestamp representing when the cache was last cleaned.  */
-  utime (interval_path, NULL);
   return 0;
 }