Guard against a potential race init-ing libCurl
This commit is contained in:
@@ -48,6 +48,8 @@
|
|||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
#include <simgear/timing/timestamp.hxx>
|
#include <simgear/timing/timestamp.hxx>
|
||||||
#include <simgear/structure/exception.hxx>
|
#include <simgear/structure/exception.hxx>
|
||||||
|
#include <simgear/threads/SGThread.hxx>
|
||||||
|
#include <simgear/threads/SGGuard.hxx>
|
||||||
|
|
||||||
#if defined( HAVE_VERSION_H ) && HAVE_VERSION_H
|
#if defined( HAVE_VERSION_H ) && HAVE_VERSION_H
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
@@ -123,6 +125,9 @@ Client::Client() :
|
|||||||
setUserAgent("SimGear-" SG_STRINGIZE(SIMGEAR_VERSION));
|
setUserAgent("SimGear-" SG_STRINGIZE(SIMGEAR_VERSION));
|
||||||
|
|
||||||
static bool didInitCurlGlobal = false;
|
static bool didInitCurlGlobal = false;
|
||||||
|
static SGMutex initMutex;
|
||||||
|
|
||||||
|
SGGuard<SGMutex> g(initMutex);
|
||||||
if (!didInitCurlGlobal) {
|
if (!didInitCurlGlobal) {
|
||||||
curl_global_init(CURL_GLOBAL_ALL);
|
curl_global_init(CURL_GLOBAL_ALL);
|
||||||
didInitCurlGlobal = true;
|
didInitCurlGlobal = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user