From 6197098541eceecdb0dcfe8a58b15f0d0773c391 Mon Sep 17 00:00:00 2001 From: James Turner Date: Wed, 13 Feb 2019 12:49:21 +0000 Subject: [PATCH] Guard against a potential race init-ing libCurl --- simgear/io/HTTPClient.cxx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/simgear/io/HTTPClient.cxx b/simgear/io/HTTPClient.cxx index 0adf0be8..d5c32af7 100644 --- a/simgear/io/HTTPClient.cxx +++ b/simgear/io/HTTPClient.cxx @@ -48,6 +48,8 @@ #include #include #include +#include +#include #if defined( HAVE_VERSION_H ) && HAVE_VERSION_H #include "version.h" @@ -123,6 +125,9 @@ Client::Client() : setUserAgent("SimGear-" SG_STRINGIZE(SIMGEAR_VERSION)); static bool didInitCurlGlobal = false; + static SGMutex initMutex; + + SGGuard g(initMutex); if (!didInitCurlGlobal) { curl_global_init(CURL_GLOBAL_ALL); didInitCurlGlobal = true;