about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRichard Nyberg <rnyberg@murmeldjur.se>2006-01-04 11:16:03 +0000
committerRichard Nyberg <rnyberg@murmeldjur.se>2006-01-04 11:16:03 +0000
commit3f8dd2ecd3e7442492e3b45b54472da3a8700eb0 (patch)
tree026c6171518a07e1d0b648d6fde776bd222d673c
parent2d2f8b03501eac746722570522ee2802507bce2a (diff)
downloadbtpd-3f8dd2ecd3e7442492e3b45b54472da3a8700eb0.tar.gz
btpd-3f8dd2ecd3e7442492e3b45b54472da3a8700eb0.zip
Fixed a broken loop. I must have forgotten that the loop variable was
unsigned when I wrote it :P

-rw-r--r--btpd/upload.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/btpd/upload.c b/btpd/upload.c
index 4ce7b42..5ae7f1b 100644
--- a/btpd/upload.c
+++ b/btpd/upload.c
@@ -62,12 +62,12 @@ choke_do(void)
         qsort(worthy, nworthy, sizeof(worthy[0]), rate_cmp);
 
         bzero(unchoked, sizeof(unchoked));
-        for (i = nworthy - 1; i >= 0 && found < m_max_downloaders - 1; i--) {
-            if ((worthy[i].p->flags & PF_P_WANT) != 0)
+        for (i = nworthy; i > 0 && found < m_max_downloaders - 1; i--) {
+            if ((worthy[i - 1].p->flags & PF_P_WANT) != 0)
                 found++;
-            if ((worthy[i].p->flags & PF_I_CHOKE) != 0)
+            if ((worthy[i - 1].p->flags & PF_I_CHOKE) != 0)
                 peer_unchoke(p);
-            unchoked[worthy[i].i] = 1;
+            unchoked[worthy[i - 1].i] = 1;
         }
 
         i = 0;