594 lines
22 KiB
Diff
594 lines
22 KiB
Diff
|
commit 76ad56c430f0b85c47115688c511d9bd4fa671d4
|
||
|
Author: Frank Ch. Eigler <fche@redhat.com>
|
||
|
Date: Wed Dec 4 15:51:12 2019 -0500
|
||
|
|
||
|
debuginfod: usability tweaks, incl. $DEBUGINFOD_PROGRESS client support
|
||
|
|
||
|
This facility allows a default progress-printing function to be
|
||
|
installed if the given environment variable is set. Some larger usage
|
||
|
experience (systemtap fetching kernels) indicates the default timeout
|
||
|
is too short, so forked it into a connection timeout (default short)
|
||
|
and a transfer timeout (default unlimited).
|
||
|
|
||
|
Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
|
||
|
|
||
|
diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c
|
||
|
index ab7b4e1..9a4a0e0 100644
|
||
|
--- a/debuginfod/debuginfod-client.c
|
||
|
+++ b/debuginfod/debuginfod-client.c
|
||
|
@@ -40,6 +40,7 @@
|
||
|
|
||
|
#include "config.h"
|
||
|
#include "debuginfod.h"
|
||
|
+#include "system.h"
|
||
|
#include <assert.h>
|
||
|
#include <dirent.h>
|
||
|
#include <stdio.h>
|
||
|
@@ -98,16 +99,16 @@ static const time_t cache_default_max_unused_age_s = 604800; /* 1 week */
|
||
|
static const char *cache_default_name = ".debuginfod_client_cache";
|
||
|
static const char *cache_path_envvar = DEBUGINFOD_CACHE_PATH_ENV_VAR;
|
||
|
|
||
|
-/* URLs of debuginfods, separated by url_delim.
|
||
|
- This env var must be set for debuginfod-client to run. */
|
||
|
+/* URLs of debuginfods, separated by url_delim. */
|
||
|
static const char *server_urls_envvar = DEBUGINFOD_URLS_ENV_VAR;
|
||
|
static const char *url_delim = " ";
|
||
|
static const char url_delim_char = ' ';
|
||
|
|
||
|
-/* Timeout for debuginfods, in seconds.
|
||
|
- This env var must be set for debuginfod-client to run. */
|
||
|
+/* Timeout for debuginfods, in seconds. */
|
||
|
static const char *server_timeout_envvar = DEBUGINFOD_TIMEOUT_ENV_VAR;
|
||
|
-static int server_timeout = 5;
|
||
|
+static const long default_connect_timeout = 5;
|
||
|
+static const long default_transfer_timeout = -1; /* unlimited */
|
||
|
+
|
||
|
|
||
|
/* Data associated with a particular CURL easy handle. Passed to
|
||
|
the write callback. */
|
||
|
@@ -400,8 +401,18 @@ debuginfod_query_server (debuginfod_client *c,
|
||
|
return fd;
|
||
|
}
|
||
|
|
||
|
- if (getenv(server_timeout_envvar))
|
||
|
- server_timeout = atoi (getenv(server_timeout_envvar));
|
||
|
+ long connect_timeout = default_connect_timeout;
|
||
|
+ long transfer_timeout = default_transfer_timeout;
|
||
|
+ const char* timeout_envvar = getenv(server_timeout_envvar);
|
||
|
+ if (timeout_envvar != NULL)
|
||
|
+ {
|
||
|
+ long ct, tt;
|
||
|
+ rc = sscanf(timeout_envvar, "%ld,%ld", &ct, &tt);
|
||
|
+ if (rc >= 1)
|
||
|
+ connect_timeout = ct;
|
||
|
+ if (rc >= 2)
|
||
|
+ transfer_timeout = tt;
|
||
|
+ }
|
||
|
|
||
|
/* make a copy of the envvar so it can be safely modified. */
|
||
|
server_urls = strdup(urls_envvar);
|
||
|
@@ -493,7 +504,10 @@ debuginfod_query_server (debuginfod_client *c,
|
||
|
CURLOPT_WRITEFUNCTION,
|
||
|
debuginfod_write_callback);
|
||
|
curl_easy_setopt(data[i].handle, CURLOPT_WRITEDATA, (void*)&data[i]);
|
||
|
- curl_easy_setopt(data[i].handle, CURLOPT_TIMEOUT, (long) server_timeout);
|
||
|
+ if (connect_timeout >= 0)
|
||
|
+ curl_easy_setopt(data[i].handle, CURLOPT_CONNECTTIMEOUT, connect_timeout);
|
||
|
+ if (transfer_timeout >= 0)
|
||
|
+ curl_easy_setopt(data[i].handle, CURLOPT_TIMEOUT, transfer_timeout);
|
||
|
curl_easy_setopt(data[i].handle, CURLOPT_FILETIME, (long) 1);
|
||
|
curl_easy_setopt(data[i].handle, CURLOPT_FOLLOWLOCATION, (long) 1);
|
||
|
curl_easy_setopt(data[i].handle, CURLOPT_FAILONERROR, (long) 1);
|
||
|
@@ -511,11 +525,32 @@ debuginfod_query_server (debuginfod_client *c,
|
||
|
long loops = 0;
|
||
|
do
|
||
|
{
|
||
|
+ /* Wait 1 second, the minimum DEBUGINFOD_TIMEOUT. */
|
||
|
+ curl_multi_wait(curlm, NULL, 0, 1000, NULL);
|
||
|
+
|
||
|
+ /* If the target file has been found, abort the other queries. */
|
||
|
+ if (target_handle != NULL)
|
||
|
+ for (int i = 0; i < num_urls; i++)
|
||
|
+ if (data[i].handle != target_handle)
|
||
|
+ curl_multi_remove_handle(curlm, data[i].handle);
|
||
|
+
|
||
|
+ CURLMcode curlm_res = curl_multi_perform(curlm, &still_running);
|
||
|
+ if (curlm_res != CURLM_OK)
|
||
|
+ {
|
||
|
+ switch (curlm_res)
|
||
|
+ {
|
||
|
+ case CURLM_CALL_MULTI_PERFORM: continue;
|
||
|
+ case CURLM_OUT_OF_MEMORY: rc = -ENOMEM; break;
|
||
|
+ default: rc = -ENETUNREACH; break;
|
||
|
+ }
|
||
|
+ goto out1;
|
||
|
+ }
|
||
|
+
|
||
|
if (c->progressfn) /* inform/check progress callback */
|
||
|
{
|
||
|
loops ++;
|
||
|
long pa = loops; /* default params for progress callback */
|
||
|
- long pb = 0;
|
||
|
+ long pb = 0; /* transfer_timeout tempting, but loops != elapsed-time */
|
||
|
if (target_handle) /* we've committed to a server; report its download progress */
|
||
|
{
|
||
|
CURLcode curl_res;
|
||
|
@@ -535,6 +570,8 @@ debuginfod_query_server (debuginfod_client *c,
|
||
|
pa = (dl > LONG_MAX ? LONG_MAX : (long)dl);
|
||
|
#endif
|
||
|
|
||
|
+ /* NB: If going through deflate-compressing proxies, this
|
||
|
+ number is likely to be unavailable, so -1 may show. */
|
||
|
#ifdef CURLINFO_CURLINFO_CONTENT_LENGTH_DOWNLOAD_T
|
||
|
curl_off_t cl;
|
||
|
curl_res = curl_easy_getinfo(target_handle,
|
||
|
@@ -555,27 +592,6 @@ debuginfod_query_server (debuginfod_client *c,
|
||
|
if ((*c->progressfn) (c, pa, pb))
|
||
|
break;
|
||
|
}
|
||
|
-
|
||
|
- /* Wait 1 second, the minimum DEBUGINFOD_TIMEOUT. */
|
||
|
- curl_multi_wait(curlm, NULL, 0, 1000, NULL);
|
||
|
-
|
||
|
- /* If the target file has been found, abort the other queries. */
|
||
|
- if (target_handle != NULL)
|
||
|
- for (int i = 0; i < num_urls; i++)
|
||
|
- if (data[i].handle != target_handle)
|
||
|
- curl_multi_remove_handle(curlm, data[i].handle);
|
||
|
-
|
||
|
- CURLMcode curlm_res = curl_multi_perform(curlm, &still_running);
|
||
|
- if (curlm_res != CURLM_OK)
|
||
|
- {
|
||
|
- switch (curlm_res)
|
||
|
- {
|
||
|
- case CURLM_CALL_MULTI_PERFORM: continue;
|
||
|
- case CURLM_OUT_OF_MEMORY: rc = -ENOMEM; break;
|
||
|
- default: rc = -ENETUNREACH; break;
|
||
|
- }
|
||
|
- goto out1;
|
||
|
- }
|
||
|
} while (still_running);
|
||
|
|
||
|
/* Check whether a query was successful. If so, assign its handle
|
||
|
@@ -674,9 +690,9 @@ debuginfod_query_server (debuginfod_client *c,
|
||
|
|
||
|
curl_multi_cleanup(curlm);
|
||
|
unlink (target_cache_tmppath);
|
||
|
+ close (fd); /* before the rmdir, otherwise it'll fail */
|
||
|
(void) rmdir (target_cache_dir); /* nop if not empty */
|
||
|
free(data);
|
||
|
- close (fd);
|
||
|
|
||
|
out0:
|
||
|
free (server_urls);
|
||
|
@@ -685,6 +701,22 @@ debuginfod_query_server (debuginfod_client *c,
|
||
|
return rc;
|
||
|
}
|
||
|
|
||
|
+
|
||
|
+/* Activate a basic form of progress tracing */
|
||
|
+static int
|
||
|
+default_progressfn (debuginfod_client *c, long a, long b)
|
||
|
+{
|
||
|
+ (void) c;
|
||
|
+
|
||
|
+ dprintf(STDERR_FILENO,
|
||
|
+ "Downloading from debuginfod %ld/%ld%s", a, b,
|
||
|
+ ((a == b) ? "\n" : "\r"));
|
||
|
+ /* XXX: include URL - stateful */
|
||
|
+
|
||
|
+ return 0;
|
||
|
+}
|
||
|
+
|
||
|
+
|
||
|
/* See debuginfod.h */
|
||
|
debuginfod_client *
|
||
|
debuginfod_begin (void)
|
||
|
@@ -693,7 +725,12 @@ debuginfod_begin (void)
|
||
|
size_t size = sizeof (struct debuginfod_client);
|
||
|
client = (debuginfod_client *) malloc (size);
|
||
|
if (client != NULL)
|
||
|
- client->progressfn = NULL;
|
||
|
+ {
|
||
|
+ if (getenv(DEBUGINFOD_PROGRESS_ENV_VAR))
|
||
|
+ client->progressfn = default_progressfn;
|
||
|
+ else
|
||
|
+ client->progressfn = NULL;
|
||
|
+ }
|
||
|
return client;
|
||
|
}
|
||
|
|
||
|
diff --git a/debuginfod/debuginfod.h b/debuginfod/debuginfod.h
|
||
|
index 6b1b1cc..33fae86 100644
|
||
|
--- a/debuginfod/debuginfod.h
|
||
|
+++ b/debuginfod/debuginfod.h
|
||
|
@@ -33,6 +33,7 @@
|
||
|
#define DEBUGINFOD_URLS_ENV_VAR "DEBUGINFOD_URLS"
|
||
|
#define DEBUGINFOD_CACHE_PATH_ENV_VAR "DEBUGINFOD_CACHE_PATH"
|
||
|
#define DEBUGINFOD_TIMEOUT_ENV_VAR "DEBUGINFOD_TIMEOUT"
|
||
|
+#define DEBUGINFOD_PROGRESS_ENV_VAR "DEBUGINFOD_PROGRESS"
|
||
|
|
||
|
/* Handle for debuginfod-client connection. */
|
||
|
typedef struct debuginfod_client debuginfod_client;
|
||
|
diff --git a/doc/debuginfod-find.1 b/doc/debuginfod-find.1
|
||
|
index a759ecb..023acbb 100644
|
||
|
--- a/doc/debuginfod-find.1
|
||
|
+++ b/doc/debuginfod-find.1
|
||
|
@@ -119,9 +119,13 @@ debuginfod instances. Alternate URL prefixes are separated by space.
|
||
|
|
||
|
.TP 21
|
||
|
.B DEBUGINFOD_TIMEOUT
|
||
|
-This environment variable governs the timeout for each debuginfod HTTP
|
||
|
-connection. A server that fails to respond within this many seconds
|
||
|
-is skipped. The default is 5.
|
||
|
+This environment variable governs the timeouts for each debuginfod
|
||
|
+HTTP connection. One or two comma-separated numbers may be given.
|
||
|
+The first is the number of seconds for the connection establishment
|
||
|
+(CURLOPT_CONNECTTIMEOUT), and the default is 5. The second is the
|
||
|
+number of seconds for the transfer completion (CURLOPT_TIMEOUT), and
|
||
|
+the default is no timeout. (Zero or negative also means "no
|
||
|
+timeout".)
|
||
|
|
||
|
.TP 21
|
||
|
.B DEBUGINFOD_CACHE_PATH
|
||
|
diff --git a/doc/debuginfod_find_debuginfo.3 b/doc/debuginfod_find_debuginfo.3
|
||
|
index be8eed0..ea8c616 100644
|
||
|
--- a/doc/debuginfod_find_debuginfo.3
|
||
|
+++ b/doc/debuginfod_find_debuginfo.3
|
||
|
@@ -163,9 +163,21 @@ debuginfod instances. Alternate URL prefixes are separated by space.
|
||
|
|
||
|
.TP 21
|
||
|
.B DEBUGINFOD_TIMEOUT
|
||
|
-This environment variable governs the timeout for each debuginfod HTTP
|
||
|
-connection. A server that fails to respond within this many seconds
|
||
|
-is skipped. The default is 5.
|
||
|
+This environment variable governs the timeouts for each debuginfod
|
||
|
+HTTP connection. One or two comma-separated numbers may be given.
|
||
|
+The first is the number of seconds for the connection establishment
|
||
|
+(CURLOPT_CONNECTTIMEOUT), and the default is 5. The second is the
|
||
|
+number of seconds for the transfer completion (CURLOPT_TIMEOUT), and
|
||
|
+the default is no timeout. (Zero or negative also means "no
|
||
|
+timeout".)
|
||
|
+
|
||
|
+.TP 21
|
||
|
+.B DEBUGINFOD_PROGRESS
|
||
|
+This environment variable governs the default progress function. If
|
||
|
+set, and if a progressfn is not explicitly set, then the library will
|
||
|
+configure a default progressfn. This function will append a simple
|
||
|
+progress message periodically to the given file. Consider using
|
||
|
+"/dev/stderr" on platforms that support it. The default is nothing.
|
||
|
|
||
|
.TP 21
|
||
|
.B DEBUGINFOD_CACHE_PATH
|
||
|
diff --git a/tests/run-debuginfod-find.sh b/tests/run-debuginfod-find.sh
|
||
|
index 6533996..4cf6138 100755
|
||
|
--- a/tests/run-debuginfod-find.sh
|
||
|
+++ b/tests/run-debuginfod-find.sh
|
||
|
@@ -89,7 +89,7 @@ wait_ready $PORT1 'ready' 1
|
||
|
export DEBUGINFOD_URLS=http://127.0.0.1:$PORT1/ # or without trailing /
|
||
|
|
||
|
# Be patient when run on a busy machine things might take a bit.
|
||
|
-export DEBUGINFOD_TIMEOUT=10
|
||
|
+export DEBUGINFOD_TIMEOUT=1,10
|
||
|
|
||
|
# We use -t0 and -g0 here to turn off time-based scanning & grooming.
|
||
|
# For testing purposes, we just sic SIGUSR1 / SIGUSR2 at the process.
|
||
|
@@ -153,8 +153,11 @@ cmp $filename F/prog2
|
||
|
cat vlog
|
||
|
grep -q Progress vlog
|
||
|
tempfiles vlog
|
||
|
-filename=`testrun ${abs_top_builddir}/debuginfod/debuginfod-find executable $BUILDID2`
|
||
|
+filename=`testrun env DEBUGINFOD_PROGRESS=1 ${abs_top_builddir}/debuginfod/debuginfod-find executable $BUILDID2 2>vlog2`
|
||
|
cmp $filename F/prog2
|
||
|
+cat vlog2
|
||
|
+grep -q Downloading vlog2
|
||
|
+tempfiles vlog2
|
||
|
filename=`testrun ${abs_top_builddir}/debuginfod/debuginfod-find source $BUILDID2 ${PWD}/prog2.c`
|
||
|
cmp $filename ${PWD}/prog2.c
|
||
|
|
||
|
|
||
|
commit 288c76775f2d27976eb269e568b53c742d973dbc
|
||
|
Author: Frank Ch. Eigler <fche@redhat.com>
|
||
|
Date: Mon Jan 6 04:29:21 2020 -0500
|
||
|
|
||
|
debuginfod: pass a distro-summary User-Agent request header
|
||
|
|
||
|
It may be useful for a debuginfod server operator to know what kinds
|
||
|
of clients make webapi requests. This is mainly as a
|
||
|
telemetry/diagnostic (though the data cannot be really trusted). It
|
||
|
may also be useful to automate downloading of distro packages to a
|
||
|
debuginfod server in the case of an unknown hex buildid. doc/testing
|
||
|
not affected as these are diagnostics.
|
||
|
|
||
|
Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
|
||
|
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
||
|
|
||
|
diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c
|
||
|
index 9a4a0e0..66ccb21 100644
|
||
|
--- a/debuginfod/debuginfod-client.c
|
||
|
+++ b/debuginfod/debuginfod-client.c
|
||
|
@@ -1,5 +1,5 @@
|
||
|
/* Retrieve ELF / DWARF / source files from the debuginfod.
|
||
|
- Copyright (C) 2019 Red Hat, Inc.
|
||
|
+ Copyright (C) 2019-2020 Red Hat, Inc.
|
||
|
This file is part of elfutils.
|
||
|
|
||
|
This file is free software; you can redistribute it and/or modify
|
||
|
@@ -58,6 +58,7 @@
|
||
|
#include <sys/syscall.h>
|
||
|
#include <sys/types.h>
|
||
|
#include <sys/stat.h>
|
||
|
+#include <sys/utsname.h>
|
||
|
#include <curl/curl.h>
|
||
|
|
||
|
/* If fts.h is included before config.h, its indirect inclusions may not
|
||
|
@@ -279,6 +280,87 @@ debuginfod_clean_cache(debuginfod_client *c,
|
||
|
#define MAX_BUILD_ID_BYTES 64
|
||
|
|
||
|
|
||
|
+static void
|
||
|
+add_extra_headers(CURL *handle)
|
||
|
+{
|
||
|
+ /* Compute a User-Agent: string to send. The more accurately this
|
||
|
+ describes this host, the likelier that the debuginfod servers
|
||
|
+ might be able to locate debuginfo for us. */
|
||
|
+
|
||
|
+ char* utspart = NULL;
|
||
|
+ struct utsname uts;
|
||
|
+ int rc = 0;
|
||
|
+ rc = uname (&uts);
|
||
|
+ if (rc == 0)
|
||
|
+ rc = asprintf(& utspart, "%s/%s", uts.sysname, uts.machine);
|
||
|
+ if (rc < 0)
|
||
|
+ utspart = NULL;
|
||
|
+
|
||
|
+ FILE *f = fopen ("/etc/os-release", "r");
|
||
|
+ if (f == NULL)
|
||
|
+ f = fopen ("/usr/lib/os-release", "r");
|
||
|
+ char *id = NULL;
|
||
|
+ char *version = NULL;
|
||
|
+ if (f != NULL)
|
||
|
+ {
|
||
|
+ while (id == NULL || version == NULL)
|
||
|
+ {
|
||
|
+ char buf[128];
|
||
|
+ char *s = &buf[0];
|
||
|
+ if (fgets (s, sizeof(buf), f) == NULL)
|
||
|
+ break;
|
||
|
+
|
||
|
+ int len = strlen (s);
|
||
|
+ if (len < 3)
|
||
|
+ continue;
|
||
|
+ if (s[len - 1] == '\n')
|
||
|
+ {
|
||
|
+ s[len - 1] = '\0';
|
||
|
+ len--;
|
||
|
+ }
|
||
|
+
|
||
|
+ char *v = strchr (s, '=');
|
||
|
+ if (v == NULL || strlen (v) < 2)
|
||
|
+ continue;
|
||
|
+
|
||
|
+ /* Split var and value. */
|
||
|
+ *v = '\0';
|
||
|
+ v++;
|
||
|
+
|
||
|
+ /* Remove optional quotes around value string. */
|
||
|
+ if (*v == '"' || *v == '\'')
|
||
|
+ {
|
||
|
+ v++;
|
||
|
+ s[len - 1] = '\0';
|
||
|
+ }
|
||
|
+ if (strcmp (s, "ID") == 0)
|
||
|
+ id = strdup (v);
|
||
|
+ if (strcmp (s, "VERSION_ID") == 0)
|
||
|
+ version = strdup (v);
|
||
|
+ }
|
||
|
+ fclose (f);
|
||
|
+ }
|
||
|
+
|
||
|
+ char *ua = NULL;
|
||
|
+ rc = asprintf(& ua, "%s/%s,%s,%s/%s",
|
||
|
+ PACKAGE_NAME, PACKAGE_VERSION,
|
||
|
+ utspart ?: "",
|
||
|
+ id ?: "",
|
||
|
+ version ?: "");
|
||
|
+ if (rc < 0)
|
||
|
+ ua = NULL;
|
||
|
+
|
||
|
+ if (ua)
|
||
|
+ curl_easy_setopt(handle, CURLOPT_USERAGENT, (void*) ua); /* implicit strdup */
|
||
|
+
|
||
|
+ free (ua);
|
||
|
+ free (id);
|
||
|
+ free (version);
|
||
|
+ free (utspart);
|
||
|
+}
|
||
|
+
|
||
|
+
|
||
|
+
|
||
|
/* Query each of the server URLs found in $DEBUGINFOD_URLS for the file
|
||
|
with the specified build-id, type (debuginfo, executable or source)
|
||
|
and filename. filename may be NULL. If found, return a file
|
||
|
@@ -514,7 +596,7 @@ debuginfod_query_server (debuginfod_client *c,
|
||
|
curl_easy_setopt(data[i].handle, CURLOPT_NOSIGNAL, (long) 1);
|
||
|
curl_easy_setopt(data[i].handle, CURLOPT_AUTOREFERER, (long) 1);
|
||
|
curl_easy_setopt(data[i].handle, CURLOPT_ACCEPT_ENCODING, "");
|
||
|
- curl_easy_setopt(data[i].handle, CURLOPT_USERAGENT, (void*) PACKAGE_STRING);
|
||
|
+ add_extra_headers(data[i].handle);
|
||
|
|
||
|
curl_multi_add_handle(curlm, data[i].handle);
|
||
|
server_url = strtok_r(NULL, url_delim, &strtok_saveptr);
|
||
|
|
||
|
commit b8d85ed024a745cff05e56c6337d95d654d5294a
|
||
|
Author: Mark Wielaard <mark@klomp.org>
|
||
|
Date: Thu Jan 2 17:02:42 2020 +0100
|
||
|
|
||
|
debuginfod: Use DEBUGINFOD_TIMEOUT as seconds to get at least 100K.
|
||
|
|
||
|
Use just one timeout using CURLOPT_LOW_SPEED_TIME (default 90 seconds)
|
||
|
and CURLOPT_LOW_SPEED_LIMIT (100K).
|
||
|
|
||
|
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
||
|
|
||
|
diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c
|
||
|
index 66ccb21..e5a2e82 100644
|
||
|
--- a/debuginfod/debuginfod-client.c
|
||
|
+++ b/debuginfod/debuginfod-client.c
|
||
|
@@ -105,10 +105,9 @@ static const char *server_urls_envvar = DEBUGINFOD_URLS_ENV_VAR;
|
||
|
static const char *url_delim = " ";
|
||
|
static const char url_delim_char = ' ';
|
||
|
|
||
|
-/* Timeout for debuginfods, in seconds. */
|
||
|
+/* Timeout for debuginfods, in seconds (to get at least 100K). */
|
||
|
static const char *server_timeout_envvar = DEBUGINFOD_TIMEOUT_ENV_VAR;
|
||
|
-static const long default_connect_timeout = 5;
|
||
|
-static const long default_transfer_timeout = -1; /* unlimited */
|
||
|
+static const long default_timeout = 90;
|
||
|
|
||
|
|
||
|
/* Data associated with a particular CURL easy handle. Passed to
|
||
|
@@ -483,18 +482,10 @@ debuginfod_query_server (debuginfod_client *c,
|
||
|
return fd;
|
||
|
}
|
||
|
|
||
|
- long connect_timeout = default_connect_timeout;
|
||
|
- long transfer_timeout = default_transfer_timeout;
|
||
|
+ long timeout = default_timeout;
|
||
|
const char* timeout_envvar = getenv(server_timeout_envvar);
|
||
|
if (timeout_envvar != NULL)
|
||
|
- {
|
||
|
- long ct, tt;
|
||
|
- rc = sscanf(timeout_envvar, "%ld,%ld", &ct, &tt);
|
||
|
- if (rc >= 1)
|
||
|
- connect_timeout = ct;
|
||
|
- if (rc >= 2)
|
||
|
- transfer_timeout = tt;
|
||
|
- }
|
||
|
+ timeout = atoi (timeout_envvar);
|
||
|
|
||
|
/* make a copy of the envvar so it can be safely modified. */
|
||
|
server_urls = strdup(urls_envvar);
|
||
|
@@ -586,10 +577,15 @@ debuginfod_query_server (debuginfod_client *c,
|
||
|
CURLOPT_WRITEFUNCTION,
|
||
|
debuginfod_write_callback);
|
||
|
curl_easy_setopt(data[i].handle, CURLOPT_WRITEDATA, (void*)&data[i]);
|
||
|
- if (connect_timeout >= 0)
|
||
|
- curl_easy_setopt(data[i].handle, CURLOPT_CONNECTTIMEOUT, connect_timeout);
|
||
|
- if (transfer_timeout >= 0)
|
||
|
- curl_easy_setopt(data[i].handle, CURLOPT_TIMEOUT, transfer_timeout);
|
||
|
+ if (timeout > 0)
|
||
|
+ {
|
||
|
+ /* Make sure there is at least some progress,
|
||
|
+ try to get at least 100K per timeout seconds. */
|
||
|
+ curl_easy_setopt (data[i].handle, CURLOPT_LOW_SPEED_TIME,
|
||
|
+ timeout);
|
||
|
+ curl_easy_setopt (data[i].handle, CURLOPT_LOW_SPEED_LIMIT,
|
||
|
+ 100 * 1024L);
|
||
|
+ }
|
||
|
curl_easy_setopt(data[i].handle, CURLOPT_FILETIME, (long) 1);
|
||
|
curl_easy_setopt(data[i].handle, CURLOPT_FOLLOWLOCATION, (long) 1);
|
||
|
curl_easy_setopt(data[i].handle, CURLOPT_FAILONERROR, (long) 1);
|
||
|
diff --git a/doc/debuginfod-find.1 b/doc/debuginfod-find.1
|
||
|
index 023acbb..e71ca29 100644
|
||
|
--- a/doc/debuginfod-find.1
|
||
|
+++ b/doc/debuginfod-find.1
|
||
|
@@ -119,13 +119,10 @@ debuginfod instances. Alternate URL prefixes are separated by space.
|
||
|
|
||
|
.TP 21
|
||
|
.B DEBUGINFOD_TIMEOUT
|
||
|
-This environment variable governs the timeouts for each debuginfod
|
||
|
-HTTP connection. One or two comma-separated numbers may be given.
|
||
|
-The first is the number of seconds for the connection establishment
|
||
|
-(CURLOPT_CONNECTTIMEOUT), and the default is 5. The second is the
|
||
|
-number of seconds for the transfer completion (CURLOPT_TIMEOUT), and
|
||
|
-the default is no timeout. (Zero or negative also means "no
|
||
|
-timeout".)
|
||
|
+This environment variable governs the timeout for each debuginfod HTTP
|
||
|
+connection. A server that fails to provide at least 100K of data
|
||
|
+within this many seconds is skipped. The default is 90 seconds. (Zero
|
||
|
+or negative means "no timeout".)
|
||
|
|
||
|
.TP 21
|
||
|
.B DEBUGINFOD_CACHE_PATH
|
||
|
diff --git a/doc/debuginfod.8 b/doc/debuginfod.8
|
||
|
index 342f524..6184bcc 100644
|
||
|
--- a/doc/debuginfod.8
|
||
|
+++ b/doc/debuginfod.8
|
||
|
@@ -366,8 +366,10 @@ or indirectly - the results would be hilarious.
|
||
|
.TP 21
|
||
|
.B DEBUGINFOD_TIMEOUT
|
||
|
This environment variable governs the timeout for each debuginfod HTTP
|
||
|
-connection. A server that fails to respond within this many seconds
|
||
|
-is skipped. The default is 5.
|
||
|
+connection. A server that fails to provide at least 100K of data
|
||
|
+within this many seconds is skipped. The default is 90 seconds. (Zero
|
||
|
+or negative means "no timeout".)
|
||
|
+
|
||
|
|
||
|
.TP 21
|
||
|
.B DEBUGINFOD_CACHE_PATH
|
||
|
diff --git a/doc/debuginfod_find_debuginfo.3 b/doc/debuginfod_find_debuginfo.3
|
||
|
index ea8c616..f6ea7a4 100644
|
||
|
--- a/doc/debuginfod_find_debuginfo.3
|
||
|
+++ b/doc/debuginfod_find_debuginfo.3
|
||
|
@@ -163,13 +163,10 @@ debuginfod instances. Alternate URL prefixes are separated by space.
|
||
|
|
||
|
.TP 21
|
||
|
.B DEBUGINFOD_TIMEOUT
|
||
|
-This environment variable governs the timeouts for each debuginfod
|
||
|
-HTTP connection. One or two comma-separated numbers may be given.
|
||
|
-The first is the number of seconds for the connection establishment
|
||
|
-(CURLOPT_CONNECTTIMEOUT), and the default is 5. The second is the
|
||
|
-number of seconds for the transfer completion (CURLOPT_TIMEOUT), and
|
||
|
-the default is no timeout. (Zero or negative also means "no
|
||
|
-timeout".)
|
||
|
+This environment variable governs the timeout for each debuginfod HTTP
|
||
|
+connection. A server that fails to provide at least 100K of data
|
||
|
+within this many seconds is skipped. The default is 90 seconds. (Zero
|
||
|
+or negative means "no timeout".)
|
||
|
|
||
|
.TP 21
|
||
|
.B DEBUGINFOD_PROGRESS
|
||
|
diff --git a/tests/run-debuginfod-find.sh b/tests/run-debuginfod-find.sh
|
||
|
index 90dafe0..4ab47a3 100755
|
||
|
--- a/tests/run-debuginfod-find.sh
|
||
|
+++ b/tests/run-debuginfod-find.sh
|
||
|
@@ -94,7 +94,7 @@ wait_ready $PORT1 'ready' 1
|
||
|
export DEBUGINFOD_URLS=http://127.0.0.1:$PORT1/ # or without trailing /
|
||
|
|
||
|
# Be patient when run on a busy machine things might take a bit.
|
||
|
-export DEBUGINFOD_TIMEOUT=1,10
|
||
|
+export DEBUGINFOD_TIMEOUT=10
|
||
|
|
||
|
# We use -t0 and -g0 here to turn off time-based scanning & grooming.
|
||
|
# For testing purposes, we just sic SIGUSR1 / SIGUSR2 at the process.
|
||
|
|
||
|
commit 6f2098114a1acbd5e320a1c5fabfa07df02b14fd
|
||
|
Author: Mark Wielaard <mark@klomp.org>
|
||
|
Date: Fri Jan 10 15:46:29 2020 +0100
|
||
|
|
||
|
doc: Fix DEBUGINFOD_PROGRESS description to just mention output on stderr.
|
||
|
|
||
|
An earlier variant of the default progress function could write to any
|
||
|
file. Which is still in the documentation. But the actual implementation
|
||
|
just uses stderr. Fix the documentation to match.
|
||
|
|
||
|
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
||
|
|
||
|
diff --git a/doc/debuginfod_find_debuginfo.3 b/doc/debuginfod_find_debuginfo.3
|
||
|
index f6ea7a4..7e5060f 100644
|
||
|
--- a/doc/debuginfod_find_debuginfo.3
|
||
|
+++ b/doc/debuginfod_find_debuginfo.3
|
||
|
@@ -173,8 +173,8 @@ or negative means "no timeout".)
|
||
|
This environment variable governs the default progress function. If
|
||
|
set, and if a progressfn is not explicitly set, then the library will
|
||
|
configure a default progressfn. This function will append a simple
|
||
|
-progress message periodically to the given file. Consider using
|
||
|
-"/dev/stderr" on platforms that support it. The default is nothing.
|
||
|
+progress message periodically to stderr. The default is no progress
|
||
|
+function output.
|
||
|
|
||
|
.TP 21
|
||
|
.B DEBUGINFOD_CACHE_PATH
|