From e544934780ac4e3afd5878f3cc02e4acacedbd67 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 31 Aug 2017 19:33:51 +0200 Subject: [PATCH] Call curl_global_init() exactly only once (1/2) --- gtk2_ardour/ardour_http.cc | 2 -- gtk2_ardour/main.cc | 7 +++++++ gtk2_ardour/sfdb_freesound_mootcher.cc | 2 -- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/gtk2_ardour/ardour_http.cc b/gtk2_ardour/ardour_http.cc index 2b16ccc2c5..ecbe76935c 100644 --- a/gtk2_ardour/ardour_http.cc +++ b/gtk2_ardour/ardour_http.cc @@ -59,8 +59,6 @@ HttpGet::setup_certificate_paths () */ assert (!ca_path && !ca_info); // call once - curl_global_init (CURL_GLOBAL_DEFAULT); - if (Glib::file_test ("/etc/pki/tls/certs/ca-bundle.crt", Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_REGULAR)) { // Fedora / RHEL, Arch ca_info = "/etc/pki/tls/certs/ca-bundle.crt"; diff --git a/gtk2_ardour/main.cc b/gtk2_ardour/main.cc index 9c9981bcc3..65ce353817 100644 --- a/gtk2_ardour/main.cc +++ b/gtk2_ardour/main.cc @@ -31,6 +31,8 @@ #include #endif +#include + #include "pbd/error.h" #include "pbd/file_utils.h" #include "pbd/textreceiver.h" @@ -288,6 +290,11 @@ int main (int argc, char *argv[]) { ARDOUR::check_for_old_configuration_files(); + /* global init is not thread safe.*/ + if (curl_global_init (CURL_GLOBAL_DEFAULT)) { + cerr << "curl_global_init() failed. The web is gone. We're all doomed." << endl; + } + fixup_bundle_environment (argc, argv, localedir); load_custom_fonts(); /* needs to happen before any gtk and pango init calls */ diff --git a/gtk2_ardour/sfdb_freesound_mootcher.cc b/gtk2_ardour/sfdb_freesound_mootcher.cc index 1f2487b5e7..51c195657b 100644 --- a/gtk2_ardour/sfdb_freesound_mootcher.cc +++ b/gtk2_ardour/sfdb_freesound_mootcher.cc @@ -142,8 +142,6 @@ std::string Mootcher::sortMethodString(enum sortMethod sort) //------------------------------------------------------------------------ void Mootcher::setcUrlOptions() { - // basic init for curl - curl_global_init(CURL_GLOBAL_ALL); // some servers don't like requests that are made without a user-agent field, so we provide one curl_easy_setopt(curl, CURLOPT_USERAGENT, "libcurl-agent/1.0"); // setup curl error buffer -- 2.30.2