From 8805d7c67b290af15dd29e440cc78be4f363bc6a Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Mon, 14 Feb 2022 16:39:52 -0600 Subject: [PATCH] refactor: remove tr_webGetTaskResponseCode() (#2628) It's not really needed anymore, and removing it is aligned with the goal of simplifying the tr_web and tr_webseed codebase. --- libtransmission/web.cc | 13 ++----------- libtransmission/web.h | 5 +---- libtransmission/webseed.cc | 14 +++----------- 3 files changed, 6 insertions(+), 26 deletions(-) diff --git a/libtransmission/web.cc b/libtransmission/web.cc index 2bb2649cb..7a1d2e72e 100644 --- a/libtransmission/web.cc +++ b/libtransmission/web.cc @@ -366,11 +366,11 @@ static void task_finish_func(void* vtask) static void tr_webThreadFunc(void* vsession); -tr_web_task* tr_webRun(tr_session* session, tr_web_options&& options) +void tr_webRun(tr_session* session, tr_web_options&& options) { if (session->isClosing()) { - return {}; + return; } if (session->web == nullptr) @@ -386,8 +386,6 @@ tr_web_task* tr_webRun(tr_session* session, tr_web_options&& options) auto* const task = new tr_web_task{ session, std::move(options) }; task->next = session->web->tasks; session->web->tasks = task; - - return task; } static void tr_webThreadFunc(void* vsession) @@ -565,10 +563,3 @@ void tr_webClose(tr_session* session, tr_web_close_mode close_mode) } } } - -long tr_webGetTaskResponseCode(tr_web_task* task) -{ - long code = 0; - curl_easy_getinfo(task->curl_easy, CURLINFO_RESPONSE_CODE, &code); - return code; -} diff --git a/libtransmission/web.h b/libtransmission/web.h index 485d3d4be..99d935887 100644 --- a/libtransmission/web.h +++ b/libtransmission/web.h @@ -13,7 +13,6 @@ #include "transmission.h" struct evbuffer; -struct tr_web_task; enum tr_web_close_mode { @@ -50,6 +49,4 @@ public: evbuffer* buffer = nullptr; }; -struct tr_web_task* tr_webRun(tr_session* session, tr_web_options&& options); - -long tr_webGetTaskResponseCode(struct tr_web_task* task); +void tr_webRun(tr_session* session, tr_web_options&& options); diff --git a/libtransmission/webseed.cc b/libtransmission/webseed.cc index d5bd8ff55..8da2d6000 100644 --- a/libtransmission/webseed.cc +++ b/libtransmission/webseed.cc @@ -66,8 +66,6 @@ public: bool dead = false; tr_block_index_t blocks_done = 0; - tr_web_task* web_task = nullptr; - long response_code = 0; }; /** @@ -360,14 +358,9 @@ void on_content_changed(evbuffer* buf, evbuffer_cb_info const* info, void* vtask fire_client_got_piece_data(w, n_added); uint32_t const len = evbuffer_get_length(buf); - if (task->response_code == 0) - { - task->response_code = tr_webGetTaskResponseCode(task->web_task); + task->webseed->connection_limiter.gotData(); - task->webseed->connection_limiter.gotData(); - } - - if (task->response_code == 206 && len >= task->block_size) + if (len >= task->block_size) { /* once we've got at least one full block, save it */ @@ -457,7 +450,6 @@ void web_response_func( { /* request finished successfully but there's still data missing. that means we've reached the end of a file and need to request the next one */ - t->response_code = 0; task_request_next_chunk(t); } else @@ -523,7 +515,7 @@ void task_request_next_chunk(tr_webseed_task* t) options.range = tr_strvJoin(std::to_string(file_offset), "-"sv, std::to_string(file_offset + this_pass - 1)); options.torrent_id = tor->uniqueId; options.buffer = t->content(); - t->web_task = tr_webRun(tor->session, std::move(options)); + tr_webRun(tor->session, std::move(options)); } } // namespace