Fixed segfault error when cleaning up libcurl

This commit is contained in:
Yousef Khadadeh 2025-10-07 12:41:21 +03:00
parent 916e415331
commit 0c9b835919
2 changed files with 21 additions and 34 deletions

View file

@ -24,21 +24,18 @@ class FileDownloader {
static std::shared_ptr<DownloadData> download_data_from_url(std::string_view url);
static void cleanup();
private:
typedef std::unique_ptr<CURL, std::function<void(CURL*)>> EasyHandle;
typedef std::unique_ptr<CURLM, std::function<void(CURLM*)>> MultiHandle;
static void add_new_handlers_to_multi();
static void download_thread_update();
struct DownloadHandler {
EasyHandle eHandle;
CURL* eHandle;
std::shared_ptr<DownloadData> data;
};
static std::mutex newDownloadsMutex;
static std::vector<DownloadHandler> newDownloads;
static std::atomic<bool> shutdownThread;
static MultiHandle mHandle;
static CURLM* mHandle;
static std::vector<DownloadHandler> currentDownloads;
static std::unique_ptr<std::thread> downloadThread;
@ -48,9 +45,6 @@ class FileDownloader {
static timeval get_timeout(CURLM* mCurl);
static int wait_if_needed(CURLM* mCurl, timeval& timeout);
static EasyHandle create_easy_handle();
static MultiHandle create_multi_handle();
static size_t write_to_string(void* contents, size_t size, size_t nmemb, void* userp);
};