Explorar el Código

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

that way :P
master
Richard Nyberg hace 19 años
padre
commit
59c62b3eb0
Se han modificado 4 ficheros con 25 adiciones y 25 borrados
  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 fichero

@@ -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);


+ 1
- 1
btpd/opts.c Ver fichero

@@ -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;


+ 1
- 1
btpd/opts.h Ver fichero

@@ -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;


+ 12
- 12
btpd/upload.c Ver fichero

@@ -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);


Cargando…
Cancelar
Guardar