Skip to content

Commit 418885b

Browse files
committed
Removed CurlGet's timeout and rely only on libcurl.
1 parent e84df1d commit 418885b

File tree

2 files changed

+1
-18
lines changed

2 files changed

+1
-18
lines changed

src/net/curl_get.cc

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ namespace torrent::net {
1717
CurlGet::CurlGet(std::string url, std::shared_ptr<std::ostream> stream)
1818
: m_url(std::move(url)),
1919
m_stream(std::move(stream)) {
20-
21-
m_task_timeout.slot() = [this]() {
22-
// TODO: Should make sure it closes/disables further callbacks.
23-
trigger_failed("Timed out");
24-
};
2520
}
2621

2722
CurlGet::~CurlGet() {
@@ -245,11 +240,6 @@ CurlGet::activate_unsafe() {
245240
if (code != CURLM_OK)
246241
throw torrent::internal_error("CurlGet::activate() error calling curl_multi_add_handle: " + std::string(curl_multi_strerror(code)));
247242

248-
// Normally libcurl should handle the timeout. But sometimes that doesn't
249-
// work right so we do a fallback timeout that just aborts the transfer.
250-
if (m_timeout != 0)
251-
torrent::this_thread::scheduler()->update_wait_for_ceil_seconds(&m_task_timeout, 20s + 1s*m_timeout);
252-
253243
m_active = true;
254244
}
255245

@@ -262,7 +252,6 @@ CurlGet::cleanup_unsafe() {
262252
if (code != CURLM_OK)
263253
throw torrent::internal_error("CurlGet::cleanup() error calling curl_multi_remove_handle: " + std::string(curl_multi_strerror(code)));
264254

265-
torrent::this_thread::scheduler()->erase(&m_task_timeout);
266255
m_active = false;
267256
}
268257

@@ -332,8 +321,6 @@ void
332321
CurlGet::trigger_done() {
333322
auto guard = lock_guard();
334323

335-
torrent::this_thread::scheduler()->erase(&m_task_timeout);
336-
337324
if (m_was_closed)
338325
return;
339326

@@ -344,8 +331,6 @@ void
344331
CurlGet::trigger_failed(const std::string& message) {
345332
auto guard = lock_guard();
346333

347-
torrent::this_thread::scheduler()->erase(&m_task_timeout);
348-
349334
if (m_was_closed)
350335
return;
351336

src/net/curl_get.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <string>
1010
#include <curl/curl.h>
1111

12-
#include "torrent/utils/scheduler.h"
12+
#include "torrent/utils/thread.h"
1313

1414
namespace torrent::net {
1515

@@ -126,9 +126,7 @@ class CurlGet {
126126
std::string m_url;
127127
std::shared_ptr<std::ostream> m_stream;
128128
uint32_t m_timeout{5 * 60};
129-
130129
std::condition_variable m_cond_closed;
131-
utils::SchedulerEntry m_task_timeout;
132130

133131
std::list<std::function<void()>> m_signal_done;
134132
std::list<std::function<void(const std::string&)>> m_signal_failed;

0 commit comments

Comments
 (0)