From 9c3817f2a52d516a88961a25e4e0d8f177b42463 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 19 Nov 2019 13:50:41 +0100 Subject: [PATCH] debuginfod: create a client connection handle for each handler thread --- debuginfod/debuginfod.cxx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/debuginfod/debuginfod.cxx b/debuginfod/debuginfod.cxx index 7d3d580f..7baf18ec 100644 --- a/debuginfod/debuginfod.cxx +++ b/debuginfod/debuginfod.cxx @@ -360,7 +360,6 @@ static struct argp argp = }; -static debuginfod_client *client; static string db_path; static sqlite3 *db; static unsigned verbose; @@ -1039,8 +1038,11 @@ static struct MHD_Response* handle_buildid (const string& buildid /* unsafe */, // is to defer to other debuginfo servers. int fd = -1; + debuginfod_client *client = debuginfod_begin (); if (client != NULL) { + debuginfod_set_progressfn (client, & debuginfod_find_progress); + if (artifacttype == "debuginfo") fd = debuginfod_find_debuginfo (client, (const unsigned char*) buildid.c_str(), @@ -1055,7 +1057,8 @@ static struct MHD_Response* handle_buildid (const string& buildid /* unsafe */, 0, suffix.c_str(), NULL); } else - fd = -ENOSYS; + fd = -errno; /* Set by debuginfod_begin. */ + debuginfod_end (client); if (fd >= 0) { @@ -2518,10 +2521,6 @@ main (int argc, char *argv[]) "cannot run database schema ddl: %s", sqlite3_errmsg(db)); } - client = debuginfod_begin (); - if (client != NULL) - debuginfod_set_progressfn (client, & debuginfod_find_progress); - // Start httpd server threads. Separate pool for IPv4 and IPv6, in // case the host only has one protocol stack. MHD_Daemon *d4 = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION @@ -2649,7 +2648,6 @@ main (int argc, char *argv[]) if (d6) MHD_stop_daemon (d6); /* With all threads known dead, we can clean up the global resources. */ - debuginfod_end (client); delete scan_concurrency_sem; rc = sqlite3_exec (db, DEBUGINFOD_SQLITE_CLEANUP_DDL, NULL, NULL, NULL); if (rc != SQLITE_OK) -- 2.18.1