]> git.meshlink.io Git - meshlink/commitdiff
Move outgoing_list to mesh->outgoings.
authorGuus Sliepen <guus@sliepen.org>
Mon, 21 Apr 2014 19:05:36 +0000 (21:05 +0200)
committerGuus Sliepen <guus@sliepen.org>
Mon, 21 Apr 2014 19:05:36 +0000 (21:05 +0200)
src/meshlink_internal.h
src/net.c
src/net.h
src/net_setup.c
src/net_socket.c

index fc40f301df0a32b412c04f1bfa5053b1b7c10cf5..04db92fcb2ceaa5f47cacaa7252c5780e1f58ae2 100644 (file)
@@ -44,7 +44,7 @@ struct meshlink_handle {
        struct splay_tree_t *nodes;
 
        struct list_t *connections;
-       struct list_t *outgoing_connections;
+       struct list_t *outgoings;
 };
 
 /// A handle for a MeshLink node.
index 74fb04b694c6daea50246471d8a3e26abdf08365..98cc8beded0272775c7f4fccdc1c27a730a8244f 100644 (file)
--- a/src/net.c
+++ b/src/net.c
@@ -206,7 +206,7 @@ static void periodic_handler(void *data) {
 
                                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;
@@ -217,7 +217,7 @@ static void periodic_handler(void *data) {
                                        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;
@@ -241,7 +241,7 @@ static void periodic_handler(void *data) {
                                        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;
@@ -252,7 +252,7 @@ static void periodic_handler(void *data) {
                        /* 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) {
@@ -262,7 +262,7 @@ static void periodic_handler(void *data) {
                                }
                                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);
                                }
                        }
                }
@@ -322,7 +322,7 @@ int reload_configuration(void) {
 
 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});
index dab40cbb677593270d7e096a3d70c843767512f4..706f56904f79cb46907662f4c918e3c60638aa8b 100644 (file)
--- a/src/net.h
+++ b/src/net.h
@@ -79,8 +79,6 @@ typedef struct outgoing_t {
        timeout_t ev;
 } outgoing_t;
 
-extern list_t *outgoing_list;
-
 extern int maxoutbufsize;
 extern int seconds_till_retry;
 extern int addressfamily;
index 62b12b55e062b835d0e66f7d31e9671f02f8cb58..1d2d47214136da8a1baccb8f4ef2cd53add63b1d 100644 (file)
@@ -416,8 +416,8 @@ void close_network_connections(void) {
                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);
index 1521208f76986ef518ce73934bcac7bfab7de7a1..ecf2c26ba9a9c8c544458d31f71795bf5bfa4f56 100644 (file)
@@ -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,10 +644,10 @@ 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;
        }
 
@@ -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,7 +679,7 @@ 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);
                }
        }
@@ -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);
 }