Parcourir la source

* Use torrent_get_piece instead of loop. Check for correctness.

* Don't decrease busy count on a piece when a block arrives in end game.
  The busy count should always be zero at that stage.
master
Richard Nyberg il y a 19 ans
Parent
révision
0ce6fa1d0c
1 fichiers modifiés avec 6 ajouts et 5 suppressions
  1. +6
    -5
      btpd/policy_if.c

+ 6
- 5
btpd/policy_if.c Voir le fichier

@@ -241,14 +241,12 @@ cm_on_block(struct peer *p, uint32_t index, uint32_t begin, uint32_t length,
off_t cbegin = index * p->tp->meta.piece_length + begin;
torrent_put_bytes(p->tp, data, cbegin, length);

struct piece *pc = BTPDQ_FIRST(&tp->getlst);
while (pc != NULL && pc->index != index)
pc = BTPDQ_NEXT(pc, entry);
struct piece *pc = torrent_get_piece(tp, index);
assert(pc != NULL);
uint32_t block = begin / PIECE_BLOCKLEN;
set_bit(pc->have_field, block);
clear_bit(pc->down_field, block);
pc->ngot++;
pc->nbusy--;

if (tp->endgame) {
BTPDQ_FOREACH(p, &tp->peers, cm_entry) {
@@ -258,6 +256,9 @@ cm_on_block(struct peer *p, uint32_t index, uint32_t begin, uint32_t length,
if (pc->ngot == pc->nblocks)
cm_on_piece(pc);
} else {
// XXX: Needs to be looked at if we introduce snubbing.
clear_bit(pc->down_field, block);
pc->nbusy--;
if (pc->ngot == pc->nblocks)
cm_on_piece(pc);
if (peer_leech_ok(p))


Chargement…
Annuler
Enregistrer