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);
-}
-
/***
****
***/
++setmePeersFrom[atom->fromFirst];
- if (clientIsDownloadingFrom (tor, msgs))
+ if (tr_peerMsgsIsClientDownloading (msgs))
++*setmePeersSendingToUs;
- if (clientIsUploadingTo (msgs))
+ if (tr_peerMsgsIsPeerDownloading (msgs))
++*setmePeersGettingFromUs;
}
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);
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)
{
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)
{
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);
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);
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);
static void
tr_webThreadFunc (void * vsession)
{
+ char * str;
CURLM * multi;
struct tr_web * web;
int taskCount = 0;
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;