From: Jordan Lee Date: Wed, 22 May 2013 19:06:54 +0000 (+0000) Subject: undo previous commit's accidental inclusion of changes to peer-msgs.* and peer-mgr.c X-Git-Tag: 2.80~26 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=094af58f294a151fa81584c6d0d6444ff0df5bb3;p=transmission undo previous commit's accidental inclusion of changes to peer-msgs.* and peer-mgr.c --- diff --git a/libtransmission/peer-mgr.c b/libtransmission/peer-mgr.c index 069fdbdfb..82bdad3be 100644 --- a/libtransmission/peer-mgr.c +++ b/libtransmission/peer-mgr.c @@ -595,6 +595,21 @@ 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); +} + /*** **** ***/ @@ -2639,10 +2654,10 @@ tr_peerMgrTorrentStats (tr_torrent * tor, ++setmePeersFrom[atom->fromFirst]; - if (tr_peerMsgsIsClientDownloading (msgs)) + if (clientIsDownloadingFrom (tor, msgs)) ++*setmePeersSendingToUs; - if (tr_peerMsgsIsPeerDownloading (msgs)) + if (clientIsUploadingTo (msgs)) ++*setmePeersGettingFromUs; } @@ -2720,8 +2735,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 = tr_peerMsgsIsClientDownloading (msgs); - stat->isUploadingTo = tr_peerMsgsIsPeerDownloading (msgs); + stat->isDownloadingFrom = clientIsDownloadingFrom (tor, msgs); + stat->isUploadingTo = clientIsUploadingTo (msgs); stat->isSeed = peerIsSeed (peer); stat->blocksToPeer = tr_historyGet (&peer->blocksSentToPeer, now, CANCEL_HISTORY_SEC); diff --git a/libtransmission/peer-msgs.c b/libtransmission/peer-msgs.c index 9826aa5fe..8b150b32c 100644 --- a/libtransmission/peer-msgs.c +++ b/libtransmission/peer-msgs.c @@ -2448,14 +2448,6 @@ 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) { @@ -2472,16 +2464,6 @@ 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) { diff --git a/libtransmission/peer-msgs.h b/libtransmission/peer-msgs.h index 205f039f9..459166bba 100644 --- a/libtransmission/peer-msgs.h +++ b/libtransmission/peer-msgs.h @@ -48,14 +48,10 @@ 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);