Working on fix "stuck" outgoing connections.
This problem occurs on "road-warriors" when tincd setups outgoing connections but you do not have any active uplink then dns-lookups will fail and any following attempt to make outgoing connections will keep failing forever.
This commit is contained in:
parent
dcf313cdbf
commit
703ed7fff6
3 changed files with 14 additions and 1 deletions
12
src/net.c
12
src/net.c
|
@ -228,7 +228,7 @@ static void periodic_handler(void *data) {
|
||||||
}
|
}
|
||||||
if (!found)
|
if (!found)
|
||||||
splay_insert(tmp_node_tree, n);
|
splay_insert(tmp_node_tree, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tmp_node_tree->count) {
|
if (tmp_node_tree->count) {
|
||||||
int r = rand() % tmp_node_tree->count;
|
int r = rand() % tmp_node_tree->count;
|
||||||
|
@ -242,11 +242,21 @@ static void periodic_handler(void *data) {
|
||||||
logger(DEBUG_CONNECTIONS, LOG_INFO, "Autoconnecting to %s", n->name);
|
logger(DEBUG_CONNECTIONS, LOG_INFO, "Autoconnecting to %s", n->name);
|
||||||
outgoing_t *outgoing = xzalloc(sizeof *outgoing);
|
outgoing_t *outgoing = xzalloc(sizeof *outgoing);
|
||||||
outgoing->name = xstrdup(n->name);
|
outgoing->name = xstrdup(n->name);
|
||||||
|
outgoing->is_alive = true;
|
||||||
list_insert_tail(outgoing_list, outgoing);
|
list_insert_tail(outgoing_list, outgoing);
|
||||||
setup_outgoing_connection(outgoing);
|
setup_outgoing_connection(outgoing);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logger(DEBUG_ALWAYS, LOG_INFO, "No more nodes available for autoconnect!");
|
logger(DEBUG_ALWAYS, LOG_INFO, "No more nodes available for autoconnect!");
|
||||||
|
for list_each(outgoing_t, outgoing, outgoing_list) {
|
||||||
|
/*
|
||||||
|
It looks like this connection "died" bacause of missing hostname->addr lookup.
|
||||||
|
Remove it and try again.
|
||||||
|
*/
|
||||||
|
if (!outgoing->is_alive) {
|
||||||
|
list_delete(outgoing_list, outgoing);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
splay_delete_tree(tmp_node_tree);
|
splay_delete_tree(tmp_node_tree);
|
||||||
} else if(nc > 3) {
|
} else if(nc > 3) {
|
||||||
|
|
|
@ -123,6 +123,7 @@ typedef struct listen_socket_t {
|
||||||
typedef struct outgoing_t {
|
typedef struct outgoing_t {
|
||||||
char *name;
|
char *name;
|
||||||
bool keep_it;
|
bool keep_it;
|
||||||
|
bool is_alive;
|
||||||
int timeout;
|
int timeout;
|
||||||
splay_tree_t *config_tree;
|
splay_tree_t *config_tree;
|
||||||
struct config_t *cfg;
|
struct config_t *cfg;
|
||||||
|
|
|
@ -620,6 +620,8 @@ void setup_outgoing_connection(outgoing_t *outgoing) {
|
||||||
outgoing->aip = outgoing->ai = get_known_addresses(n);
|
outgoing->aip = outgoing->ai = get_known_addresses(n);
|
||||||
if(!outgoing->ai) {
|
if(!outgoing->ai) {
|
||||||
logger(DEBUG_ALWAYS, LOG_DEBUG, "No address known for %s", outgoing->name);
|
logger(DEBUG_ALWAYS, LOG_DEBUG, "No address known for %s", outgoing->name);
|
||||||
|
retry_outgoing(outgoing);
|
||||||
|
outgoing->is_alive = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue