Change AutoConnect from int to bool.
The proper value is 3, not 2 or 4, and 5 is right out. So just hardcode this value, and only have the option to turn AutoConnect on or off.
This commit is contained in:
parent
27acb5d047
commit
332b55d472
5 changed files with 27 additions and 24 deletions
|
@ -204,7 +204,7 @@ static void periodic_handler(void *data) {
|
|||
nc++;
|
||||
}
|
||||
|
||||
if(nc < autoconnect) {
|
||||
if(nc < 3) {
|
||||
/* Not enough active connections, try to add one.
|
||||
Choose a random node, if we don't have a connection to it,
|
||||
and we are not already trying to make one, create an
|
||||
|
@ -238,7 +238,7 @@ static void periodic_handler(void *data) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
} else if(nc > autoconnect) {
|
||||
} else if(nc > 3) {
|
||||
/* Too many active connections, try to remove one.
|
||||
Choose a random outgoing connection to a node
|
||||
that has at least one other connection.
|
||||
|
@ -264,7 +264,7 @@ static void periodic_handler(void *data) {
|
|||
}
|
||||
}
|
||||
|
||||
if(nc >= autoconnect) {
|
||||
if(nc >= 3) {
|
||||
/* If we have enough active connections,
|
||||
remove any pending outgoing connections.
|
||||
*/
|
||||
|
|
|
@ -137,7 +137,7 @@ extern int udp_sndbuf;
|
|||
extern int max_connection_burst;
|
||||
extern bool do_prune;
|
||||
extern char *myport;
|
||||
extern int autoconnect;
|
||||
extern bool autoconnect;
|
||||
extern bool disablebuggypeers;
|
||||
extern int contradicting_add_edge;
|
||||
extern int contradicting_del_edge;
|
||||
|
|
|
@ -52,7 +52,7 @@ char *proxyport;
|
|||
char *proxyuser;
|
||||
char *proxypass;
|
||||
proxytype_t proxytype;
|
||||
int autoconnect;
|
||||
bool autoconnect;
|
||||
bool disablebuggypeers;
|
||||
|
||||
char *scriptinterpreter;
|
||||
|
@ -630,9 +630,15 @@ bool setup_myself_reloadable(void) {
|
|||
if(!get_config_int(lookup_config(config_tree, "KeyExpire"), &keylifetime))
|
||||
keylifetime = 3600;
|
||||
|
||||
get_config_int(lookup_config(config_tree, "AutoConnect"), &autoconnect);
|
||||
if(autoconnect < 0)
|
||||
autoconnect = 0;
|
||||
config_t *cfg = lookup_config(config_tree, "AutoConnect");
|
||||
if(cfg) {
|
||||
if(!get_config_bool(cfg, &autoconnect)) {
|
||||
// Some backwards compatibility with when this option was an int
|
||||
int val = 0;
|
||||
get_config_int(cfg, &val);
|
||||
autoconnect = val;
|
||||
}
|
||||
}
|
||||
|
||||
get_config_bool(lookup_config(config_tree, "DisableBuggyPeers"), &disablebuggypeers);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue