summary refs log tree commit diff
diff options
context:
space:
mode:
authorRichard Nyberg <rnyberg@murmeldjur.se>2005-07-30 18:45:20 +0000
committerRichard Nyberg <rnyberg@murmeldjur.se>2005-07-30 18:45:20 +0000
commit1e1846b8f32948e946fc1acd84706e06fc4e30f5 (patch)
tree06eaaa7c76d2fc447c9f900f0ac9f79c05719086
parentc11a57b8cb8204b966abf45fdf4e7d1e25676012 (diff)
downloadbtpd-1e1846b8f32948e946fc1acd84706e06fc4e30f5.tar.gz
btpd-1e1846b8f32948e946fc1acd84706e06fc4e30f5.zip
Better tests. peer_laden is needed beacuse the peer might have
gotten new request if the piece was fully downloaded and found
to be bad.

-rw-r--r--btpd/policy_if.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/btpd/policy_if.c b/btpd/policy_if.c
index 7aeadaa..88d49fe 100644
--- a/btpd/policy_if.c
+++ b/btpd/policy_if.c
@@ -261,7 +261,7 @@ cm_on_block(struct peer *p, uint32_t index, uint32_t begin, uint32_t length,
 
     if (tp->endgame) {
 	BTPDQ_FOREACH(p, &tp->peers, cm_entry) {
-	    if (peer_has(p, index) && peer_leech_ok(p))
+	    if (peer_has(p, index) && p->nreqs_out > 0)
 		peer_cancel(p, index, begin, length);
 	}
 	if (pc->ngot == pc->nblocks)
@@ -272,7 +272,7 @@ cm_on_block(struct peer *p, uint32_t index, uint32_t begin, uint32_t length,
 	pc->nbusy--;
 	if (pc->ngot == pc->nblocks)
 	    cm_on_piece(pc);
-	if (peer_leech_ok(p))
+	if (peer_leech_ok(p) && !peer_laden(p))
 	    cm_assign_requests(p);
     }
 }