throw libc_exception (errno, "cannot create temporary file");
// NB: don't unlink (tmppath), as fdcache will take charge of it.
- rc = archive_read_data_into_fd (a, fd);
+ // NB: this can take many uninterruptible seconds for a huge file
+ rc = archive_read_data_into_fd (a, fd);
if (rc != ARCHIVE_OK) // e.g. ENOSPC!
{
close (fd);
elf_classify (fd, executable_p, debuginfo_p, buildid, sourcefiles);
else
throw libc_exception(errno, string("open ") + rps);
- inc_metric ("scanned_total","source","file");
+ add_metric ("scanned_bytes_total","source","file",
+ st.st_size);
+ inc_metric ("scanned_files_total","source","file");
}
// NB: we catch exceptions here too, so that we can
// cache the corrupt-elf case (!executable_p &&
if (verbose > 3)
obatched(clog) << "libarchive scanning " << rps << endl;
- while(1) // parse cpio archive entries
+ while(1) // parse archive entries
{
- try
+ if (interrupted)
+ break;
+
+ try
{
struct archive_entry *e;
rc = archive_read_next_header (a, &e);
st.st_mtime,
my_fts_executable, my_fts_debuginfo, my_fts_sref, my_fts_sdef,
my_fts_sref_complete_p);
- inc_metric ("scanned_total","source",archive_extension + " archive");
+ add_metric ("scanned_bytes_total","source",archive_extension + " archive",
+ st.st_size);
+ inc_metric ("scanned_files_total","source",archive_extension + " archive");
add_metric("found_debuginfo_total","source",archive_extension + " archive",
my_fts_debuginfo);
add_metric("found_executable_total","source",archive_extension + " archive",
if (verbose > 2)
obatched(clog) << "fts traversing " << f->fts_path << endl;
- /* Found a file. Convert it to an absolute path, so
- the buildid database does not have relative path
- names that are unresolvable from a subsequent run
- in a different cwd. */
- char *rp = realpath(f->fts_path, NULL);
- if (rp == NULL)
- continue; // ignore dangling symlink or such
- string rps = string(rp);
- free (rp);
-
- bool ri = !regexec (&file_include_regex, rps.c_str(), 0, 0, 0);
- bool rx = !regexec (&file_exclude_regex, rps.c_str(), 0, 0, 0);
- if (!ri || rx)
- {
- if (verbose > 3)
- obatched(clog) << "fts skipped by regex " << (!ri ? "I" : "") << (rx ? "X" : "") << endl;
- fts_regex ++;
- if (!ri)
- inc_metric("traversed_total","type","regex-skipped-I");
- if (rx)
- inc_metric("traversed_total","type","regex-skipped-X");
- continue;
- }
-
switch (f->fts_info)
{
case FTS_F:
- scanq.push_back (make_pair(rps, *f->fts_statp));
- inc_metric("traversed_total","type","file");
+ {
+ /* Found a file. Convert it to an absolute path, so
+ the buildid database does not have relative path
+ names that are unresolvable from a subsequent run
+ in a different cwd. */
+ char *rp = realpath(f->fts_path, NULL);
+ if (rp == NULL)
+ continue; // ignore dangling symlink or such
+ string rps = string(rp);
+ free (rp);
+
+ bool ri = !regexec (&file_include_regex, rps.c_str(), 0, 0, 0);
+ bool rx = !regexec (&file_exclude_regex, rps.c_str(), 0, 0, 0);
+ if (!ri || rx)
+ {
+ if (verbose > 3)
+ obatched(clog) << "fts skipped by regex "
+ << (!ri ? "I" : "") << (rx ? "X" : "") << endl;
+ fts_regex ++;
+ if (!ri)
+ inc_metric("traversed_total","type","file-skipped-I");
+ if (rx)
+ inc_metric("traversed_total","type","file-skipped-X");
+ }
+ else
+ {
+ scanq.push_back (make_pair(rps, *f->fts_statp));
+ inc_metric("traversed_total","type","file");
+ }
+ }
break;
case FTS_ERR:
inc_metric("traversed_total","type","error");
break;
+ case FTS_SL: // ignore, but count because debuginfod -L would traverse these
+ inc_metric("traversed_total","type","symlink");
+ break;
+
case FTS_D: // ignore
inc_metric("traversed_total","type","directory");
break;
kill -USR1 $PID1
# All rpms need to be in the index, except the dummy permission-000 one
rpms=$(find R -name \*rpm | grep -v nothing | wc -l)
-wait_ready $PORT1 'scanned_total{source=".rpm archive"}' $rpms
+wait_ready $PORT1 'scanned_files_total{source=".rpm archive"}' $rpms
txz=$(find Z -name \*tar.xz | wc -l)
-wait_ready $PORT1 'scanned_total{source=".tar.xz archive"}' $txz
+wait_ready $PORT1 'scanned_files_total{source=".tar.xz archive"}' $txz
tb2=$(find Z -name \*tar.bz2 | wc -l)
-wait_ready $PORT1 'scanned_total{source=".tar.bz2 archive"}' $tb2
+wait_ready $PORT1 'scanned_files_total{source=".tar.bz2 archive"}' $tb2
kill -USR1 $PID1 # two hits of SIGUSR1 may be needed to resolve .debug->dwz->srefs
# Expect all source files found in the rpms (they are all called hello.c :)
kill -USR1 $PID2
# All debs need to be in the index
debs=$(find D -name \*.deb | wc -l)
- wait_ready $PORT2 'scanned_total{source=".deb archive"}' `expr $debs`
+ wait_ready $PORT2 'scanned_files_total{source=".deb archive"}' `expr $debs`
ddebs=$(find D -name \*.ddeb | wc -l)
- wait_ready $PORT2 'scanned_total{source=".ddeb archive"}' `expr $ddebs`
+ wait_ready $PORT2 'scanned_files_total{source=".ddeb archive"}' `expr $ddebs`
# ubuntu
archive_test f17a29b5a25bd4960531d82aa6b07c8abe84fa66 "" ""
curl -s http://127.0.0.1:$PORT1/metrics | grep 'http_responses_transfer_bytes_sum'
curl -s http://127.0.0.1:$PORT1/metrics | grep 'fdcache_'
curl -s http://127.0.0.1:$PORT1/metrics | grep 'error_count'
+curl -s http://127.0.0.1:$PORT1/metrics | grep 'traversed_total'
+curl -s http://127.0.0.1:$PORT1/metrics | grep 'scanned_bytes_total'
# And generate a few errors into the second debuginfod's logs, for analysis just below
curl -s http://127.0.0.1:$PORT2/badapi > /dev/null || true