Remove the lock.

As we now build a new request handle for every request, we don't need
a lock.

libcurl itself is thread safe as long as we don't share a handle.
This commit is contained in:
Matthieu Gautier 2023-02-07 10:22:07 +01:00
parent 95ebb6a492
commit 1aa8521e15
2 changed files with 18 additions and 28 deletions

View File

@ -115,11 +115,6 @@ Aria2::Aria2():
}
}
Aria2::~Aria2()
{
std::unique_lock<std::mutex> lock(m_lock);
}
void Aria2::close()
{
saveSession();
@ -139,8 +134,6 @@ std::string Aria2::doRequest(const MethodCall& methodCall)
std::stringstream outStream;
CURLcode res;
long response_code;
{
std::unique_lock<std::mutex> lock(m_lock);
char curlErrorBuffer[CURL_ERROR_SIZE];
CURL* p_curl = curl_easy_init();
curl_easy_setopt(p_curl, CURLOPT_URL, "http://localhost/rpc");
@ -160,7 +153,6 @@ std::string Aria2::doRequest(const MethodCall& methodCall)
}
curl_easy_getinfo(p_curl, CURLINFO_RESPONSE_CODE, &response_code);
curl_easy_cleanup(p_curl);
}
auto responseContent = outStream.str();
if (response_code != 200) {

View File

@ -12,7 +12,6 @@
#include "xmlrpc.h"
#include <memory>
#include <mutex>
#include <curl/curl.h>
namespace kiwix {
@ -24,12 +23,11 @@ class Aria2
int m_port;
std::string m_secret;
std::string m_downloadDir;
std::mutex m_lock;
std::string doRequest(const MethodCall& methodCall);
public:
Aria2();
virtual ~Aria2();
virtual ~Aria2() = default;
void close();
std::string addUri(const std::vector<std::string>& uri, const std::vector<std::pair<std::string, std::string>>& options = {});