Ver código fonte

Change the downloaders option to max-uploads. I find it much less confusing

that way :P
master
Richard Nyberg 19 anos atrás
pai
commit
59c62b3eb0
4 arquivos alterados com 25 adições e 25 exclusões
  1. +11
    -11
      btpd/main.c
  2. +1
    -1
      btpd/opts.c
  3. +1
    -1
      btpd/opts.h
  4. +12
    -12
      btpd/upload.c

+ 11
- 11
btpd/main.c Ver arquivo

@@ -72,7 +72,7 @@ static void
usage(void) usage(void)
{ {
printf( printf(
"The BitTorrent Protocol Daemon.\n" "btpd is the BitTorrent Protocol Daemon.\n"
"\n" "\n"
"Usage: btpd [-d dir] [-p port] [more options...]\n" "Usage: btpd [-d dir] [-p port] [more options...]\n"
"\n" "\n"
@@ -88,14 +88,6 @@ usage(void)
"-d dir\n" "-d dir\n"
"\tThe directory in which to run btpd. Default is '$HOME/.btpd'.\n" "\tThe directory in which to run btpd. Default is '$HOME/.btpd'.\n"
"\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" "--help\n"
"\tShow this text.\n" "\tShow this text.\n"
"\n" "\n"
@@ -105,6 +97,14 @@ usage(void)
"--max-peers n\n" "--max-peers n\n"
"\tLimit the amount of peers to n.\n" "\tLimit the amount of peers to n.\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" "--no-daemon\n"
"\tKeep the btpd process in the foregorund and log to std{out,err}.\n" "\tKeep the btpd process in the foregorund and log to std{out,err}.\n"
"\tThis option is intended for debugging purposes.\n" "\tThis option is intended for debugging purposes.\n"
@@ -127,7 +127,7 @@ static struct option longopts[] = {
{ "bw-in", required_argument, &longval, 1 }, { "bw-in", required_argument, &longval, 1 },
{ "bw-out", required_argument, &longval, 2 }, { "bw-out", required_argument, &longval, 2 },
{ "prealloc", required_argument, &longval, 3 }, { "prealloc", required_argument, &longval, 3 },
{ "downloaders", required_argument, &longval, 4 }, { "max-uploads", required_argument, &longval, 4 },
{ "max-peers", required_argument, &longval, 5 }, { "max-peers", required_argument, &longval, 5 },
{ "no-daemon", no_argument, &longval, 6 }, { "no-daemon", no_argument, &longval, 6 },
{ "logfile", required_argument, &longval, 7 }, { "logfile", required_argument, &longval, 7 },
@@ -165,7 +165,7 @@ main(int argc, char **argv)
cm_alloc_size = atoi(optarg) * 1024; cm_alloc_size = atoi(optarg) * 1024;
break; break;
case 4: case 4:
net_max_downloaders = atoi(optarg); net_max_uploads = atoi(optarg);
break; break;
case 5: case 5:
net_max_peers = atoi(optarg); net_max_peers = atoi(optarg);


+ 1
- 1
btpd/opts.c Ver arquivo

@@ -6,7 +6,7 @@ uint32_t btpd_logmask = BTPD_L_ALL;
#else #else
uint32_t btpd_logmask = BTPD_L_BTPD | BTPD_L_ERROR; uint32_t btpd_logmask = BTPD_L_BTPD | BTPD_L_ERROR;
#endif #endif
int net_max_downloaders = -2; int net_max_uploads = -2;
unsigned net_max_peers; unsigned net_max_peers;
unsigned net_bw_limit_in; unsigned net_bw_limit_in;
unsigned net_bw_limit_out; unsigned net_bw_limit_out;


+ 1
- 1
btpd/opts.h Ver arquivo

@@ -3,7 +3,7 @@


extern const char *btpd_dir; extern const char *btpd_dir;
extern uint32_t btpd_logmask; extern uint32_t btpd_logmask;
extern int net_max_downloaders; extern int net_max_uploads;
extern unsigned net_max_peers; extern unsigned net_max_peers;
extern unsigned net_bw_limit_in; extern unsigned net_bw_limit_in;
extern unsigned net_bw_limit_out; extern unsigned net_bw_limit_out;


+ 12
- 12
btpd/upload.c Ver arquivo

@@ -7,7 +7,7 @@
static struct event m_choke_timer; static struct event m_choke_timer;
static unsigned m_npeers; static unsigned m_npeers;
static struct peer_tq m_peerq = BTPDQ_HEAD_INITIALIZER(m_peerq); 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_sort {
struct peer *p; struct peer *p;
@@ -32,12 +32,12 @@ rate_cmp(const void *arg1, const void *arg2)
static void static void
choke_do(void) choke_do(void)
{ {
if (m_max_downloaders < 0) { if (m_max_uploads < 0) {
struct peer *p; struct peer *p;
BTPDQ_FOREACH(p, &m_peerq, ul_entry) BTPDQ_FOREACH(p, &m_peerq, ul_entry)
if (p->flags & PF_I_CHOKE) if (p->flags & PF_I_CHOKE)
peer_unchoke(p); peer_unchoke(p);
} else if (m_max_downloaders == 0) { } else if (m_max_uploads == 0) {
struct peer *p; struct peer *p;
BTPDQ_FOREACH(p, &m_peerq, ul_entry) BTPDQ_FOREACH(p, &m_peerq, ul_entry)
if ((p->flags & PF_I_CHOKE) == 0) if ((p->flags & PF_I_CHOKE) == 0)
@@ -69,7 +69,7 @@ choke_do(void)
qsort(worthy, nworthy, sizeof(worthy[0]), rate_cmp); qsort(worthy, nworthy, sizeof(worthy[0]), rate_cmp);


bzero(unchoked, sizeof(unchoked)); 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) if ((worthy[i].p->flags & PF_P_WANT) != 0)
found++; found++;
if ((worthy[i].p->flags & PF_I_CHOKE) != 0) if ((worthy[i].p->flags & PF_I_CHOKE) != 0)
@@ -80,7 +80,7 @@ choke_do(void)
i = 0; i = 0;
BTPDQ_FOREACH(p, &m_peerq, ul_entry) { BTPDQ_FOREACH(p, &m_peerq, ul_entry) {
if (!unchoked[i]) { 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) if (p->flags & PF_P_WANT)
found++; found++;
if (p->flags & PF_I_CHOKE) if (p->flags & PF_I_CHOKE)
@@ -177,19 +177,19 @@ ul_on_uninterest(struct peer *p)
void void
ul_init(void) ul_init(void)
{ {
if (net_max_downloaders >= -1) if (net_max_uploads >= -1)
m_max_downloaders = net_max_downloaders; m_max_uploads = net_max_uploads;
else { else {
if (net_bw_limit_out == 0) if (net_bw_limit_out == 0)
m_max_downloaders = 8; m_max_uploads = 8;
else if (net_bw_limit_out < (10 << 10)) else if (net_bw_limit_out < (10 << 10))
m_max_downloaders = 2; m_max_uploads = 2;
else if (net_bw_limit_out < (20 << 10)) else if (net_bw_limit_out < (20 << 10))
m_max_downloaders = 3; m_max_uploads = 3;
else if (net_bw_limit_out < (40 << 10)) else if (net_bw_limit_out < (40 << 10))
m_max_downloaders = 4; m_max_uploads = 4;
else 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); evtimer_set(&m_choke_timer, choke_cb, NULL);


||||||
x
 
000:0
Carregando…
Cancelar
Salvar