libeech

BitTorrent library
git clone git://z3bra.org/libeech.git
Log | Files | Refs | README | LICENSE

commit e308b69b6b819eed9e2e29cab389ce4879c61d8b
parent 115117034d00618ff235ffc27b60277035a0e759
Author: z3bra <contactatz3bradotorg>
Date:   Thu Jul  5 08:15:00 +0200

Permit requesting multiple pieces

Diffstat:
libeech.c | 6+++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/libeech.c b/libeech.c @@ -525,7 +525,10 @@ pwptxrq(struct torrent *t, struct peer *p) ssize_t bl; /* Find a missing piece we can get from the peer */ - for (i = 0; i >= t->npiece || (!bit(t->bf, i) && bit(p->bf, i)); i++); + for (i = 0; i < t->npiece && (bit(t->bf, i) || !bit(p->bf, i)); i++); + + if (i == t->npiece) + return -1; p->piece.n = i; p->piece.sz = (i == t->npiece - 1) ? t->sz % t->psz : t->psz; @@ -621,6 +624,7 @@ pwprxpc(struct torrent *t, struct peer *p, size_t sz, char *pl) setbit(t->bf, p->piece.n); for (b = t->peers; b; b = b->next) pwptxhv(b, p->piece.n); + p->piece.n = -1; } return 0;