From c93658f92997f942a2a119fbf47f462fd5722576 Mon Sep 17 00:00:00 2001 From: heinrich5991 Date: Mon, 23 May 2022 17:18:55 +0200 Subject: [PATCH] Make sure we don't accidentally initialize libcurl in a thread --- src/engine/shared/http.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/engine/shared/http.cpp b/src/engine/shared/http.cpp index fbfc47458..0df0e46a3 100644 --- a/src/engine/shared/http.cpp +++ b/src/engine/shared/http.cpp @@ -20,6 +20,7 @@ // TODO: Non-global pls? static CURLSH *gs_Share; static LOCK gs_aLocks[CURL_LOCK_DATA_LAST + 1]; +static bool gs_Initialized = false; static int GetLockIndex(int Data) { @@ -105,6 +106,8 @@ bool HttpInit(IStorage *pStorage) signal(SIGPIPE, SIG_IGN); #endif + gs_Initialized = true; + return false; } @@ -141,6 +144,7 @@ CHttpRequest::~CHttpRequest() void CHttpRequest::Run() { + dbg_assert(gs_Initialized, "must initialize HTTP before running HTTP requests"); int FinalState; if(!BeforeInit()) {