X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fnet_socket.c;h=80fe84cac2876aff23b5e7826a5df7fdae3bb84a;hb=8fc838f88fad6d6a632f9d4e6906e31931c765e3;hp=60f4de1d270404e434e58af93ee0bcc8fbfc2f4e;hpb=1e08f518b26db292ad81ce44fc0df06f4df3a869;p=meshlink diff --git a/src/net_socket.c b/src/net_socket.c index 60f4de1d..80fe84ca 100644 --- a/src/net_socket.c +++ b/src/net_socket.c @@ -43,7 +43,6 @@ int max_connection_burst = 100; listen_socket_t listen_socket[MAXSOCKETS]; int listen_sockets; -list_t *outgoing_list = NULL; /* Setup sockets */ @@ -645,17 +644,17 @@ static void free_outgoing(outgoing_t *outgoing) { 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; } /* Make sure there is one outgoing_t in the list for each ConnectTo. */ // TODO: Drop support for ConnectTo since AutoConnect is now always on? - for(config_t *cfg = lookup_config(config_tree, "ConnectTo"); cfg; cfg = lookup_config_next(config_tree, cfg)) { + for(config_t *cfg = lookup_config(mesh->config, "ConnectTo"); cfg; cfg = lookup_config_next(mesh->config, cfg)) { char *name; get_config_string(cfg, &name); @@ -669,7 +668,7 @@ void try_outgoing_connections(void) { 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; @@ -680,14 +679,14 @@ void try_outgoing_connections(void) { 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); } } /* Terminate any connections whose outgoing_t is to be deleted. */ - for list_each(connection_t, c, connection_list) { + for list_each(connection_t, c, mesh->connections) { if(c->outgoing && c->outgoing->timeout == -1) { c->outgoing = NULL; logger(DEBUG_CONNECTIONS, LOG_INFO, "No more outgoing connection to %s", c->name); @@ -697,7 +696,7 @@ void try_outgoing_connections(void) { /* 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); }