Changeset 13903


Ignore:
Timestamp:
Jan 30, 2013, 8:06:12 PM (8 years ago)
Author:
jordan
Message:

(libT) increment the announced downloadCount only when the piece becomes complete.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer-mgr.c

    r13900 r13903  
    16711671tr_peerMgrPieceCompleted (tr_torrent * tor, tr_piece_index_t p)
    16721672{
    1673   int i;
    1674   int peerCount;
    1675   tr_peer ** peers;
    1676   tr_swarm * s = tor->swarm;
    1677 
    1678   /* notify the peers that we now have this piece */
    1679   peerCount = tr_ptrArraySize (&s->peers);
    1680   peers = (tr_peer**) tr_ptrArrayBase (&s->peers);
    1681   for (i=0; i<peerCount; ++i)
    1682     tr_peerMsgsHave (peers[i]->msgs, p);
     1673  bool pieceCameFromPeers = false;
     1674  tr_swarm * const s = tor->swarm;
     1675  const tr_peer ** peer = (const tr_peer **) tr_ptrArrayBase (&s->peers);
     1676  const tr_peer ** const pend = peer + tr_ptrArraySize (&s->peers);
     1677
     1678  /* walk through our peers */
     1679  for ( ; peer!=pend; ++peer)
     1680    {
     1681      /* notify the peer that we now have this piece */
     1682      tr_peerMsgsHave ((*peer)->msgs, p);
     1683
     1684      if (!pieceCameFromPeers)
     1685        pieceCameFromPeers = tr_bitfieldHas (&(*peer)->blame, p);
     1686    }
     1687
     1688  if (pieceCameFromPeers) /* webseed downloads don't belong in announce totals */
     1689    tr_announcerAddBytes (tor, TR_ANN_DOWN, tr_torPieceCountBytes (tor, p));
    16831690
    16841691  /* bookkeeping */
     
    17941801          const tr_piece_index_t p = e->pieceIndex;
    17951802          const tr_block_index_t block = _tr_block (tor, p, e->offset);
    1796           if (peer->msgs != NULL) /* webseed downloads don't belong in announce totals */
    1797             tr_announcerAddBytes (tor, TR_ANN_DOWN, tr_torPieceCountBytes (tor, p));
    17981803          cancelAllRequestsForBlock (s, block, peer);
    17991804          tr_historyAdd (&peer->blocksSentToClient, tr_time(), 1);
Note: See TracChangeset for help on using the changeset viewer.