about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRichard Nyberg <rnyberg@murmeldjur.se>2006-02-10 09:24:07 +0000
committerRichard Nyberg <rnyberg@murmeldjur.se>2006-02-10 09:24:07 +0000
commit59c62b3eb0f5edd02642fc9ddfa09a92076c402a (patch)
tree448bfc5a0038754422dda163f5548fbe0510b3cd
parent31f0e727dfee03dd1cea50afd8f1d966fa714650 (diff)
downloadbtpd-59c62b3eb0f5edd02642fc9ddfa09a92076c402a.tar.gz
btpd-59c62b3eb0f5edd02642fc9ddfa09a92076c402a.zip
Change the downloaders option to max-uploads. I find it much less confusing
that way :P

-rw-r--r--btpd/main.c22
-rw-r--r--btpd/opts.c2
-rw-r--r--btpd/opts.h2
-rw-r--r--btpd/upload.c24
4 files changed, 25 insertions, 25 deletions
diff --git a/btpd/main.c b/btpd/main.c
index e397eee..7d11d64 100644
--- a/btpd/main.c
+++ b/btpd/main.c
@@ -72,7 +72,7 @@ static void
 usage(void)
 {
     printf(
-        "The BitTorrent Protocol Daemon.\n"
+        "btpd is the BitTorrent Protocol Daemon.\n"
         "\n"
         "Usage: btpd [-d dir] [-p port] [more options...]\n"
         "\n"
@@ -88,14 +88,6 @@ usage(void)
         "-d dir\n"
         "\tThe directory in which to run btpd. Default is '$HOME/.btpd'.\n"
         "\n"
-        "--downloaders n\n"
-        "\tControls the number of simultaneous uploads.\n"
-        "\tThe possible values are:\n"
-        "\t\tn < -1 : Choose n >= 2 based on --bw-out (default).\n"
-        "\t\tn = -1 : Upload to every interested peer.\n"
-        "\t\tn =  0 : Dont't upload to anyone.\n"
-        "\t\tn >  0 : Upload to at most n peers simultaneously.\n"
-        "\n"
         "--help\n"
         "\tShow this text.\n"
         "\n"
@@ -105,6 +97,14 @@ usage(void)
         "--max-peers n\n"
         "\tLimit the amount of peers to n.\n"
         "\n"
+        "--max-uploads n\n"
+        "\tControls the number of simultaneous uploads.\n"
+        "\tThe possible values are:\n"
+        "\t\tn < -1 : Choose n >= 2 based on --bw-out (default).\n"
+        "\t\tn = -1 : Upload to every interested peer.\n"
+        "\t\tn =  0 : Dont't upload to anyone.\n"
+        "\t\tn >  0 : Upload to at most n peers simultaneously.\n"
+        "\n"
         "--no-daemon\n"
         "\tKeep the btpd process in the foregorund and log to std{out,err}.\n"
         "\tThis option is intended for debugging purposes.\n"
@@ -127,7 +127,7 @@ static struct option longopts[] = {
     { "bw-in",  required_argument,      &longval,       1 },
     { "bw-out", required_argument,      &longval,       2 },
     { "prealloc", required_argument,    &longval,       3 },
-    { "downloaders", required_argument, &longval,       4 },
+    { "max-uploads", required_argument, &longval,       4 },
     { "max-peers", required_argument,   &longval,       5 },
     { "no-daemon", no_argument,         &longval,       6 },
     { "logfile", required_argument,     &longval,       7 },
@@ -165,7 +165,7 @@ main(int argc, char **argv)
                 cm_alloc_size = atoi(optarg) * 1024;
                 break;
             case 4:
-                net_max_downloaders = atoi(optarg);
+                net_max_uploads = atoi(optarg);
                 break;
             case 5:
                 net_max_peers = atoi(optarg);
diff --git a/btpd/opts.c b/btpd/opts.c
index 2fc3d1c..cccf2da 100644
--- a/btpd/opts.c
+++ b/btpd/opts.c
@@ -6,7 +6,7 @@ uint32_t btpd_logmask = BTPD_L_ALL;
 #else
 uint32_t btpd_logmask =  BTPD_L_BTPD | BTPD_L_ERROR;
 #endif
-int net_max_downloaders = -2;
+int net_max_uploads = -2;
 unsigned net_max_peers;
 unsigned net_bw_limit_in;
 unsigned net_bw_limit_out;
diff --git a/btpd/opts.h b/btpd/opts.h
index 4f48fa2..688c5fe 100644
--- a/btpd/opts.h
+++ b/btpd/opts.h
@@ -3,7 +3,7 @@
 
 extern const char *btpd_dir;
 extern uint32_t btpd_logmask;
-extern int net_max_downloaders;
+extern int net_max_uploads;
 extern unsigned net_max_peers;
 extern unsigned net_bw_limit_in;
 extern unsigned net_bw_limit_out;
diff --git a/btpd/upload.c b/btpd/upload.c
index db7d5a3..f7c9866 100644
--- a/btpd/upload.c
+++ b/btpd/upload.c
@@ -7,7 +7,7 @@
 static struct event m_choke_timer;
 static unsigned m_npeers;
 static struct peer_tq m_peerq = BTPDQ_HEAD_INITIALIZER(m_peerq);
-static int m_max_downloaders;
+static int m_max_uploads;
 
 struct peer_sort {
     struct peer *p;
@@ -32,12 +32,12 @@ rate_cmp(const void *arg1, const void *arg2)
 static void
 choke_do(void)
 {
-    if (m_max_downloaders < 0) {
+    if (m_max_uploads < 0) {
         struct peer *p;
         BTPDQ_FOREACH(p, &m_peerq, ul_entry)
             if (p->flags & PF_I_CHOKE)
                 peer_unchoke(p);
-    } else if (m_max_downloaders == 0) {
+    } else if (m_max_uploads == 0) {
         struct peer *p;
         BTPDQ_FOREACH(p, &m_peerq, ul_entry)
             if ((p->flags & PF_I_CHOKE) == 0)
@@ -69,7 +69,7 @@ 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--) {
+        for (i = nworthy - 1; i >= 0 && found < m_max_uploads - 1; i--) {
             if ((worthy[i].p->flags & PF_P_WANT) != 0)
                 found++;
             if ((worthy[i].p->flags & PF_I_CHOKE) != 0)
@@ -80,7 +80,7 @@ choke_do(void)
         i = 0;
         BTPDQ_FOREACH(p, &m_peerq, ul_entry) {
             if (!unchoked[i]) {
-                if (found < m_max_downloaders && !peer_full(p)) {
+                if (found < m_max_uploads && !peer_full(p)) {
                     if (p->flags & PF_P_WANT)
                         found++;
                     if (p->flags & PF_I_CHOKE)
@@ -177,19 +177,19 @@ ul_on_uninterest(struct peer *p)
 void
 ul_init(void)
 {
-    if (net_max_downloaders >= -1)
-        m_max_downloaders = net_max_downloaders;
+    if (net_max_uploads >= -1)
+        m_max_uploads = net_max_uploads;
     else {
         if (net_bw_limit_out == 0)
-            m_max_downloaders = 8;
+            m_max_uploads = 8;
         else if (net_bw_limit_out < (10 << 10))
-            m_max_downloaders = 2;
+            m_max_uploads = 2;
         else if (net_bw_limit_out < (20 << 10))
-            m_max_downloaders = 3;
+            m_max_uploads = 3;
         else if (net_bw_limit_out < (40 << 10))
-            m_max_downloaders = 4;
+            m_max_uploads = 4;
         else
-            m_max_downloaders = 5 + (net_bw_limit_out / (100 << 10));
+            m_max_uploads = 5 + (net_bw_limit_out / (100 << 10));
     }
 
     evtimer_set(&m_choke_timer, choke_cb, NULL);