mirror of
https://github.com/transmission/transmission
synced 2025-03-03 18:25:35 +00:00
(libT) don't start the web thread until we have a task to feed to curl
This commit is contained in:
parent
58862d0fc4
commit
fcdec9a8bc
4 changed files with 21 additions and 20 deletions
|
@ -728,10 +728,6 @@ tr_sessionInitImpl (void * vdata)
|
|||
|
||||
tr_statsInit (session);
|
||||
|
||||
tr_webInit (session);
|
||||
while (session->web == NULL)
|
||||
tr_wait_msec (50);
|
||||
|
||||
tr_sessionSet (session, &settings);
|
||||
|
||||
tr_udpInit (session);
|
||||
|
@ -1756,6 +1752,8 @@ sessionCloseImpl (void * vsession)
|
|||
|
||||
assert (tr_isSession (session));
|
||||
|
||||
session->isClosing = true;
|
||||
|
||||
free_incoming_peer_port (session);
|
||||
|
||||
if (session->isLPDEnabled)
|
||||
|
|
|
@ -110,6 +110,7 @@ struct tr_session
|
|||
bool isBlocklistEnabled;
|
||||
bool isPrefetchEnabled;
|
||||
bool isTorrentDoneScriptEnabled;
|
||||
bool isClosing;
|
||||
bool isClosed;
|
||||
bool isIncompleteFileNamingEnabled;
|
||||
bool isRatioLimited;
|
||||
|
|
|
@ -247,6 +247,8 @@ tr_webRun (tr_session * session,
|
|||
NULL);
|
||||
}
|
||||
|
||||
static void tr_webThreadFunc (void * vsession);
|
||||
|
||||
struct tr_web_task *
|
||||
tr_webRunWithBuffer (tr_session * session,
|
||||
const char * url,
|
||||
|
@ -256,12 +258,20 @@ tr_webRunWithBuffer (tr_session * session,
|
|||
void * done_func_user_data,
|
||||
struct evbuffer * buffer)
|
||||
{
|
||||
struct tr_web * web = session->web;
|
||||
struct tr_web_task * task = NULL;
|
||||
|
||||
if (web != NULL)
|
||||
if (!session->isClosing)
|
||||
{
|
||||
struct tr_web_task * task = tr_new0 (struct tr_web_task, 1);
|
||||
if (session->web == NULL)
|
||||
{
|
||||
tr_threadNew (tr_webThreadFunc, session);
|
||||
|
||||
while (session->web == NULL)
|
||||
tr_wait_msec (20);
|
||||
}
|
||||
|
||||
task = tr_new0 (struct tr_web_task, 1);
|
||||
task = tr_new0 (struct tr_web_task, 1);
|
||||
task->session = session;
|
||||
task->url = tr_strdup (url);
|
||||
task->range = tr_strdup (range);
|
||||
|
@ -271,14 +281,13 @@ tr_webRunWithBuffer (tr_session * session,
|
|||
task->response = buffer ? buffer : evbuffer_new ();
|
||||
task->freebuf = buffer ? NULL : task->response;
|
||||
|
||||
tr_lockLock (web->taskLock);
|
||||
task->next = web->tasks;
|
||||
web->tasks = task;
|
||||
tr_lockUnlock (web->taskLock);
|
||||
return task;
|
||||
tr_lockLock (session->web->taskLock);
|
||||
task->next = session->web->tasks;
|
||||
session->web->tasks = task;
|
||||
tr_lockUnlock (session->web->taskLock);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return task;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -450,11 +459,6 @@ tr_webThreadFunc (void * vsession)
|
|||
session->web = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
tr_webInit (tr_session * session)
|
||||
{
|
||||
tr_threadNew (tr_webThreadFunc, session);
|
||||
}
|
||||
|
||||
void
|
||||
tr_webClose (tr_session * session, tr_web_close_mode close_mode)
|
||||
|
|
|
@ -30,8 +30,6 @@ typedef enum
|
|||
}
|
||||
tr_web_task_info;
|
||||
|
||||
void tr_webInit (tr_session * session);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TR_WEB_CLOSE_WHEN_IDLE,
|
||||
|
|
Loading…
Reference in a new issue