From 41589f06c2bb54da6025d0da704542eb96162a59 Mon Sep 17 00:00:00 2001 From: Jari Sundell Date: Wed, 11 Jun 2025 17:04:40 +0200 Subject: [PATCH] Converted curl/http to be thread-safe. --- src/core/http_queue.cc | 6 +++--- src/core/http_queue.h | 2 +- src/display/window_http_queue.cc | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/http_queue.cc b/src/core/http_queue.cc index 0f694982..04e2b504 100644 --- a/src/core/http_queue.cc +++ b/src/core/http_queue.cc @@ -8,13 +8,13 @@ namespace core { HttpQueue::iterator -HttpQueue::insert(const std::string& url, std::iostream* s) { - auto itr = base_type::insert(end(), torrent::net_thread::http_stack()->create(url, s)); +HttpQueue::insert(const std::string& url, std::iostream* stream) { + auto itr = base_type::insert(end(), torrent::net::HttpGet(url, stream)); itr->add_done_slot([this, itr]() { erase(itr); }); itr->add_failed_slot([this, itr](auto) { erase(itr); }); - itr->start(); + torrent::net_thread::http_stack()->start_get(*itr); for (auto& slot : m_signal_insert) slot(*itr); diff --git a/src/core/http_queue.h b/src/core/http_queue.h index 93a98945..4ea61ca2 100644 --- a/src/core/http_queue.h +++ b/src/core/http_queue.h @@ -38,7 +38,7 @@ public: // // Consider adding a flag to indicate whetever HttpQueue should // delete the stream. - iterator insert(const std::string& url, std::iostream* s); + iterator insert(const std::string& url, std::iostream* stream); void erase(iterator itr); void clear(); diff --git a/src/display/window_http_queue.cc b/src/display/window_http_queue.cc index df34026d..10b6a7dc 100644 --- a/src/display/window_http_queue.cc +++ b/src/display/window_http_queue.cc @@ -126,7 +126,7 @@ WindowHttpQueue::receive_erase(torrent::net::HttpGet http_get) { if (itr == m_container.end()) throw std::logic_error("WindowHttpQueue::receive_erase(...) tried to remove an object we don't have"); - itr->m_http = nullptr; + itr->m_http = torrent::net::HttpGet(); itr->m_timer = torrent::this_thread::cached_time() + 4s; mark_dirty();