struct splay_tree_t *nodes;
struct list_t *connections;
- struct list_t *outgoing_connections;
+ struct list_t *outgoings;
};
/// A handle for a MeshLink node.
bool found = false;
- for list_each(outgoing_t, outgoing, outgoing_list) {
+ for list_each(outgoing_t, outgoing, mesh->outgoings) {
if(!strcmp(outgoing->name, n->name)) {
found = true;
break;
logger(DEBUG_CONNECTIONS, LOG_INFO, "Autoconnecting to %s", n->name);
outgoing_t *outgoing = xzalloc(sizeof *outgoing);
outgoing->name = xstrdup(n->name);
- list_insert_tail(outgoing_list, outgoing);
+ list_insert_tail(mesh->outgoings, outgoing);
setup_outgoing_connection(outgoing);
}
break;
break;
logger(DEBUG_CONNECTIONS, LOG_INFO, "Autodisconnecting from %s", c->name);
- list_delete(outgoing_list, c->outgoing);
+ list_delete(mesh->outgoings, c->outgoing);
c->outgoing = NULL;
terminate_connection(c, c->status.active);
break;
/* If we have enough active connections,
remove any pending outgoing connections.
*/
- for list_each(outgoing_t, o, outgoing_list) {
+ for list_each(outgoing_t, o, mesh->outgoings) {
bool found = false;
for list_each(connection_t, c, mesh->connections) {
if(c->outgoing == o) {
}
if(!found) {
logger(DEBUG_CONNECTIONS, LOG_INFO, "Cancelled outgoing connection to %s", o->name);
- list_delete_node(outgoing_list, node);
+ list_delete_node(mesh->outgoings, node);
}
}
}
void retry(void) {
/* Reset the reconnection timers for all outgoing connections */
- for list_each(outgoing_t, outgoing, outgoing_list) {
+ for list_each(outgoing_t, outgoing, mesh->outgoings) {
outgoing->timeout = 0;
if(outgoing->ev.cb)
timeout_set(&outgoing->ev, &(struct timeval){0, 0});
timeout_t ev;
} outgoing_t;
-extern list_t *outgoing_list;
-
extern int maxoutbufsize;
extern int seconds_till_retry;
extern int addressfamily;
terminate_connection(c, false);
}
- if(outgoing_list)
- list_delete_list(outgoing_list);
+ if(mesh->outgoings)
+ list_delete_list(mesh->outgoings);
if(mesh->self && mesh->self->connection) {
terminate_connection(mesh->self->connection, false);
listen_socket_t listen_socket[MAXSOCKETS];
int listen_sockets;
-list_t *outgoing_list = NULL;
/* Setup sockets */
void try_outgoing_connections(void) {
/* If there is no outgoing list yet, create one. Otherwise, mark all outgoings as deleted. */
- if(!outgoing_list) {
- outgoing_list = list_alloc((list_action_t)free_outgoing);
+ if(!mesh->outgoings) {
+ mesh->outgoings = list_alloc((list_action_t)free_outgoing);
} else {
- for list_each(outgoing_t, outgoing, outgoing_list)
+ for list_each(outgoing_t, outgoing, mesh->outgoings)
outgoing->timeout = -1;
}
bool found = false;
- for list_each(outgoing_t, outgoing, outgoing_list) {
+ for list_each(outgoing_t, outgoing, mesh->outgoings) {
if(!strcmp(outgoing->name, name)) {
found = true;
outgoing->timeout = 0;
if(!found) {
outgoing_t *outgoing = xzalloc(sizeof *outgoing);
outgoing->name = name;
- list_insert_tail(outgoing_list, outgoing);
+ list_insert_tail(mesh->outgoings, outgoing);
setup_outgoing_connection(outgoing);
}
}
/* Delete outgoing_ts for which there is no ConnectTo. */
- for list_each(outgoing_t, outgoing, outgoing_list)
+ for list_each(outgoing_t, outgoing, mesh->outgoings)
if(outgoing->timeout == -1)
- list_delete_node(outgoing_list, node);
+ list_delete_node(mesh->outgoings, node);
}