]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
debuginfod-client.c: Skip empty file creation for cancelled queries
authorAaron Merey <amerey@redhat.com>
Fri, 17 Mar 2023 15:20:50 +0000 (11:20 -0400)
committerAaron Merey <amerey@redhat.com>
Fri, 17 Mar 2023 15:20:50 +0000 (11:20 -0400)
Empty files in the client cache are used to indicate that contacted
servers could not find a requested resource.  Future queries for this
resource will not be attempted until the cache_miss_s duration has
passed.

Currently these empty files are also created when a query is cancelled
through the client's progressfn.  This can occur, for example, when a
user cancels a download with ctrl-c.

This prevents user-cancelled queries from being retried promptly without
having to modify cache_miss_s.  Fix this by skipping the creation of an
empty cache file when progressfn cancels a query.

Signed-off-by: Aaron Merey <amerey@redhat.com>
debuginfod/ChangeLog
debuginfod/debuginfod-client.c

index f861eb72a1c9e6c2b591967f2514d49472d26e09..5db5a753fec381bfbcf9dbf2ad9449a04d76e7c1 100644 (file)
@@ -1,3 +1,8 @@
+2023-03-17  Aaron Merey  <amerey@redhat.com>
+
+       * debuginfod-client.c (debuginfod_query_server): Do not create an
+       empty file in the cache if the query was cancelled by the progressfn.
+
 2023-02-07  Aaron Merey  <amerey@redhat.com>
 
        * debuginfod-client.c (cache_find_section): Avoid returning -ENOENT
index ef4d47e32a33a5b40c9ef68b16c2e483285dbd38..b33408eb10857c2fc7e1b77f75d7b8ce09550a38 100644 (file)
@@ -1667,9 +1667,9 @@ debuginfod_query_server (debuginfod_client *c,
         }
     } while (num_msg > 0);
 
-  /* Create an empty file named as $HOME/.cache if the query fails
-     with ENOENT.*/
-  if (rc == -ENOENT)
+  /* Create an empty file in the cache if the query fails with ENOENT and
+     it wasn't cancelled early.  */
+  if (rc == -ENOENT && !c->progressfn_cancel)
     {
       int efd = open (target_cache_path, O_CREAT|O_EXCL, DEFFILEMODE);
       if (efd >= 0)