(trunk, libT) #5356 'only set CURLOPT_COOKIEFILE if cookies.txt exists on startup' -- fixed.
This commit is contained in:
parent
68665b939d
commit
d81f956daa
|
@ -595,21 +595,6 @@ tr_peerMgrFree (tr_peerMgr * manager)
|
|||
tr_free (manager);
|
||||
}
|
||||
|
||||
static int
|
||||
clientIsDownloadingFrom (const tr_torrent * tor, const tr_peerMsgs * p)
|
||||
{
|
||||
if (!tr_torrentHasMetadata (tor))
|
||||
return true;
|
||||
|
||||
return tr_peerMsgsIsClientInterested (p) && !tr_peerMsgsIsClientChoked (p);
|
||||
}
|
||||
|
||||
static int
|
||||
clientIsUploadingTo (const tr_peerMsgs * p)
|
||||
{
|
||||
return tr_peerMsgsIsPeerInterested (p) && !tr_peerMsgsIsPeerChoked (p);
|
||||
}
|
||||
|
||||
/***
|
||||
****
|
||||
***/
|
||||
|
@ -2654,10 +2639,10 @@ tr_peerMgrTorrentStats (tr_torrent * tor,
|
|||
|
||||
++setmePeersFrom[atom->fromFirst];
|
||||
|
||||
if (clientIsDownloadingFrom (tor, msgs))
|
||||
if (tr_peerMsgsIsClientDownloading (msgs))
|
||||
++*setmePeersSendingToUs;
|
||||
|
||||
if (clientIsUploadingTo (msgs))
|
||||
if (tr_peerMsgsIsPeerDownloading (msgs))
|
||||
++*setmePeersGettingFromUs;
|
||||
}
|
||||
|
||||
|
@ -2735,8 +2720,8 @@ tr_peerMgrPeerStats (const tr_torrent * tor, int * setmeCount)
|
|||
stat->clientIsChoked = tr_peerMsgsIsClientChoked (msgs);
|
||||
stat->clientIsInterested = tr_peerMsgsIsClientInterested (msgs);
|
||||
stat->isIncoming = tr_peerMsgsIsIncomingConnection (msgs);
|
||||
stat->isDownloadingFrom = clientIsDownloadingFrom (tor, msgs);
|
||||
stat->isUploadingTo = clientIsUploadingTo (msgs);
|
||||
stat->isDownloadingFrom = tr_peerMsgsIsClientDownloading (msgs);
|
||||
stat->isUploadingTo = tr_peerMsgsIsPeerDownloading (msgs);
|
||||
stat->isSeed = peerIsSeed (peer);
|
||||
|
||||
stat->blocksToPeer = tr_historyGet (&peer->blocksSentToPeer, now, CANCEL_HISTORY_SEC);
|
||||
|
|
|
@ -2448,6 +2448,14 @@ tr_peerMsgsIsPeerInterested (const tr_peerMsgs * msgs)
|
|||
return msgs->peer_is_interested;
|
||||
}
|
||||
|
||||
bool
|
||||
tr_peerMsgsIsPeerDownloading (const tr_peerMsgs * msgs)
|
||||
{
|
||||
assert (tr_isPeerMsgs (msgs));
|
||||
|
||||
return msgs->peer_is_interested && !msgs->peer_is_choked;
|
||||
}
|
||||
|
||||
bool
|
||||
tr_peerMsgsIsClientChoked (const tr_peerMsgs * msgs)
|
||||
{
|
||||
|
@ -2464,6 +2472,16 @@ tr_peerMsgsIsClientInterested (const tr_peerMsgs * msgs)
|
|||
return msgs->client_is_interested;
|
||||
}
|
||||
|
||||
bool
|
||||
tr_peerMsgsIsClientDownloading (const tr_peerMsgs * msgs)
|
||||
{
|
||||
assert (tr_isPeerMsgs (msgs));
|
||||
|
||||
return msgs->client_is_interested
|
||||
&& !msgs->client_is_choked
|
||||
&& tr_torrentHasMetadata (msgs->torrent);
|
||||
}
|
||||
|
||||
bool
|
||||
tr_peerMsgsIsUtpConnection (const tr_peerMsgs * msgs)
|
||||
{
|
||||
|
|
|
@ -48,10 +48,14 @@ bool tr_peerMsgsIsPeerChoked (const tr_peerMsgs * msgs);
|
|||
|
||||
bool tr_peerMsgsIsPeerInterested (const tr_peerMsgs * msgs);
|
||||
|
||||
bool tr_peerMsgsIsPeerDownloading (const tr_peerMsgs * msgs);
|
||||
|
||||
bool tr_peerMsgsIsClientChoked (const tr_peerMsgs * msgs);
|
||||
|
||||
bool tr_peerMsgsIsClientInterested (const tr_peerMsgs * msgs);
|
||||
|
||||
bool tr_peerMsgsIsClientDownloading (const tr_peerMsgs * msgs);
|
||||
|
||||
time_t tr_peerMsgsGetConnectionAge (const tr_peerMsgs * msgs);
|
||||
|
||||
bool tr_peerMsgsIsUtpConnection (const tr_peerMsgs * msgs);
|
||||
|
|
|
@ -182,7 +182,6 @@ createEasy (tr_session * s, struct tr_web * web, struct tr_web_task * task)
|
|||
task->timeout_secs = getTimeoutFromURL (task);
|
||||
|
||||
curl_easy_setopt (e, CURLOPT_AUTOREFERER, 1L);
|
||||
curl_easy_setopt (e, CURLOPT_COOKIEFILE, web->cookie_filename);
|
||||
curl_easy_setopt (e, CURLOPT_ENCODING, "gzip;q=1.0, deflate, identity");
|
||||
curl_easy_setopt (e, CURLOPT_FOLLOWLOCATION, 1L);
|
||||
curl_easy_setopt (e, CURLOPT_MAXREDIRS, -1L);
|
||||
|
@ -216,6 +215,9 @@ createEasy (tr_session * s, struct tr_web * web, struct tr_web_task * task)
|
|||
if (task->cookies != NULL)
|
||||
curl_easy_setopt (e, CURLOPT_COOKIE, task->cookies);
|
||||
|
||||
if (web->cookie_filename != NULL)
|
||||
curl_easy_setopt (e, CURLOPT_COOKIEFILE, web->cookie_filename);
|
||||
|
||||
if (task->range != NULL)
|
||||
{
|
||||
curl_easy_setopt (e, CURLOPT_RANGE, task->range);
|
||||
|
@ -370,6 +372,7 @@ tr_select (int nfds,
|
|||
static void
|
||||
tr_webThreadFunc (void * vsession)
|
||||
{
|
||||
char * str;
|
||||
CURLM * multi;
|
||||
struct tr_web * web;
|
||||
int taskCount = 0;
|
||||
|
@ -395,7 +398,11 @@ tr_webThreadFunc (void * vsession)
|
|||
tr_logAddNamedInfo ("web", "NB: this only works if you built against libcurl with openssl or gnutls, NOT nss");
|
||||
tr_logAddNamedInfo ("web", "NB: invalid certs will show up as 'Could not connect to tracker' like many other errors");
|
||||
}
|
||||
web->cookie_filename = tr_buildPath (session->configDir, "cookies.txt", NULL);
|
||||
|
||||
str = tr_buildPath (session->configDir, "cookies.txt", NULL);
|
||||
if (tr_fileExists (str, NULL))
|
||||
web->cookie_filename = tr_strdup (str);
|
||||
tr_free (str);
|
||||
|
||||
multi = curl_multi_init ();
|
||||
session->web = web;
|
||||
|
|
Loading…
Reference in New Issue