mirror of
https://github.com/transmission/transmission
synced 2025-03-11 14:43:42 +00:00
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.
This commit is contained in:
parent
0adc6b95de
commit
8805d7c67b
3 changed files with 6 additions and 26 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue