]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
debuginfod-find: Restore DEBUGINFOD_PROGRESS behaviour
authorAaron Merey <amerey@redhat.com>
Wed, 11 Mar 2026 14:13:54 +0000 (10:13 -0400)
committerAaron Merey <amerey@redhat.com>
Fri, 13 Mar 2026 22:10:09 +0000 (18:10 -0400)
Commit d7cb72f7 changed debuginfod-find to always set a progress
callback function in order to handle interrupts during downloading.

Previously debuginfod-find set a progressfn only when the -v command
line option was given.  If the DEBUGINFOD_PROGRESS environment variable
is set, libdebuginfod automatically sets a default progressfn as long as
no other progressfn has been set using debuginfod_set_progressfn.

Commit d7cb72f7 therefore resulted in DEBUGINFOD_PROGRESS no longer
affecting debuginfod-find when invoked without -v.

This patch restores the old behaviour: when DEBUGINFOD_PROGRESS is set
and -v is not given, the default progressfn will trigger during
downloading.

Signed-off-by: Aaron Merey <amerey@redhat.com>
debuginfod/debuginfod-find.c
tests/run-debuginfod-artifact-running.sh

index 39de65c3c39a57bd3ba3e3ec071676b6c1388ea9..75fb1101ebc19c39c8ecd1db4571d514093cee3c 100644 (file)
@@ -68,6 +68,7 @@ static const struct argp_option options[] =
 static debuginfod_client *client;
 static int verbose;
 static volatile sig_atomic_t interrupted;
+static bool saw_progress_envvar;
 
 static void
 handle_sigint(int signo __attribute__((__unused__)))
@@ -75,13 +76,19 @@ handle_sigint(int signo __attribute__((__unused__)))
   interrupted = 1;
 }
 
-int progressfn(debuginfod_client *c __attribute__((__unused__)),
-              long a, long b)
+static int
+progressfn(debuginfod_client *c, long a, long b)
 {
   if (interrupted)
     return 1;
   if (verbose < 1)
-    return 0;
+    {
+      /* Fallback to the default progressfn if verbose isn't set and
+        DEBUGINFOD_PROGRESS is set.  */
+      if (saw_progress_envvar)
+       return debuginfod_default_progressfn (c, a, b);
+      return 0;
+    }
 
   static bool first = true;
   static struct timespec last;
@@ -153,6 +160,9 @@ main(int argc, char** argv)
   sa.sa_handler = handle_sigint;
   sigaction (SIGINT, &sa, NULL);
 
+  if (getenv(DEBUGINFOD_PROGRESS_ENV_VAR) != NULL)
+    saw_progress_envvar = true;
+
   debuginfod_set_progressfn (client, & progressfn);
 
   /* Exercise user data pointer, to support testing only. */
index 2d5d834d6d122226b9e70129a905d0da2fc78821..746f4dc31fa5a04aa6ad137e84e32e6520f3cbae 100755 (executable)
@@ -112,6 +112,11 @@ grep -q 'Progress' vlog2
 filename=`testrun ${abs_top_builddir}/debuginfod/debuginfod-find source $BUILDID2 ${PWD}/prog2.c`
 cmp $filename ${PWD}/prog2.c
 
+# Check that debuginfod-find with DEBUGINFOD_PROGRESS set and no -v uses
+# libdebuginfod's default progress callback function
+rm -rf $DEBUGINFOD_CACHE_PATH/$BUILDID2/executable
+filename=`testrun env DEBUGINFOD_PROGRESS=1 ${abs_top_builddir}/debuginfod/debuginfod-find executable $BUILDID2 2>vlog2`
+grep -q 'Downloading.*http' vlog2
 
 kill $PID1
 wait $PID1