summary refs log tree commit diff
diff options
context:
space:
mode:
authorRichard Nyberg <rnyberg@murmeldjur.se>2005-07-21 09:29:19 +0000
committerRichard Nyberg <rnyberg@murmeldjur.se>2005-07-21 09:29:19 +0000
commit0c794ac33a5359137ae044220addb731627908c0 (patch)
tree372e19250d30c42ece89d7285a6a02546249c5d2
parentc8a115a0f01f4c15cd46d4f4ba7ad43a5e3857e5 (diff)
downloadbtpd-0c794ac33a5359137ae044220addb731627908c0.tar.gz
btpd-0c794ac33a5359137ae044220addb731627908c0.zip
The test for if we should call cm_on_undownload or not wasn't
totally correct. Since there's a possibility that we've assigned
requests to peer and then decreased the wanted level, we could've
missed peers with requests but a wanted level of zero.

Now we check if the peer has any requests instead.

-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 5f6804c..882767a 100644
--- a/btpd/policy_if.c
+++ b/btpd/policy_if.c
@@ -81,7 +81,7 @@ cm_on_undownload(struct peer *p)
 void
 cm_on_choke(struct peer *p)
 {
-    if (peer_wanted(p))
+    if (p->nreqs_out > 0)
 	cm_on_undownload(p);
 }
 
@@ -217,7 +217,7 @@ cm_on_lost_peer(struct peer *p)
 	if (peer_has(p, i))
 	    tp->piece_count[i]--;
 
-    if (peer_leech_ok(p))
+    if (p->nreqs_out > 0)
 	cm_on_undownload(p);
 #if 0
     struct piece *pc = BTPDQ_FIRST(&tp->getlst);