Call curl_global_init() exactly only once (1/2)
authorRobin Gareus <robin@gareus.org>
Thu, 31 Aug 2017 17:33:51 +0000 (19:33 +0200)
committerRobin Gareus <robin@gareus.org>
Thu, 31 Aug 2017 18:08:47 +0000 (20:08 +0200)
gtk2_ardour/ardour_http.cc
gtk2_ardour/main.cc
gtk2_ardour/sfdb_freesound_mootcher.cc

index 2b16ccc2c5e4709eaa1bc011304260a5cf20d61a..ecbe76935c1b3ff50d08d1f1f43168c84c02b1f6 100644 (file)
@@ -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";
index 9c9981bcc382087363e888ec44f32ef781681868..65ce3538171563984cadf191f43d3d84fc9954c2 100644 (file)
@@ -31,6 +31,8 @@
 #include <fftw3.h>
 #endif
 
+#include <curl/curl.h>
+
 #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 */
index 1f2487b5e7426407b41b3326796cd83ff3bca35d..51c195657b26dbc4914c2ea0b19e1e020d2bb678 100644 (file)
@@ -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