Remove redundant connection_t::status.active field.
[tinc] / src / net.c
index 8fe3c51..91b9305 100644 (file)
--- a/src/net.c
+++ b/src/net.c
@@ -97,8 +97,6 @@ void purge(void) {
 void terminate_connection(connection_t *c, bool report) {
        logger(DEBUG_CONNECTIONS, LOG_NOTICE, "Closing connection with %s (%s)", c->name, c->hostname);
 
-       c->status.active = false;
-
        if(c->node && c->node->connection == c)
                c->node->connection = NULL;
 
@@ -155,7 +153,7 @@ static void timeout_handler(void *data) {
                        continue;
 
                if(c->last_ping_time + pingtimeout <= now.tv_sec) {
-                       if(c->status.active) {
+                       if(c->edge) {
                                if(c->status.pinged) {
                                        logger(DEBUG_CONNECTIONS, LOG_INFO, "%s (%s) didn't respond to PING in %ld seconds", c->name, c->hostname, (long)now.tv_sec - c->last_ping_time);
                                } else if(c->last_ping_time + pinginterval <= now.tv_sec) {
@@ -170,7 +168,7 @@ static void timeout_handler(void *data) {
                                else
                                        logger(DEBUG_CONNECTIONS, LOG_WARNING, "Timeout from %s (%s) during authentication", c->name, c->hostname);
                        }
-                       terminate_connection(c, c->status.active);
+                       terminate_connection(c, c->edge);
                }
        }
 
@@ -204,7 +202,7 @@ static void periodic_handler(void *data) {
                /* Count number of active connections */
                int nc = 0;
                for list_each(connection_t, c, connection_list) {
-                       if(c->status.active && !c->status.control)
+                       if(c->edge)
                                nc++;
                }
 
@@ -251,7 +249,7 @@ static void periodic_handler(void *data) {
                        int i = 0;
 
                        for list_each(connection_t, c, connection_list) {
-                               if(!c->status.active || c->status.control)
+                               if(!c->edge)
                                        continue;
 
                                if(i++ != r)
@@ -263,7 +261,7 @@ static void periodic_handler(void *data) {
                                logger(DEBUG_CONNECTIONS, LOG_INFO, "Autodisconnecting from %s", c->name);
                                list_delete(outgoing_list, c->outgoing);
                                c->outgoing = NULL;
-                               terminate_connection(c, c->status.active);
+                               terminate_connection(c, c->edge);
                                break;
                        }
                }
@@ -293,7 +291,7 @@ static void periodic_handler(void *data) {
 
 void handle_meta_connection_data(connection_t *c) {
        if (!receive_meta(c)) {
-               terminate_connection(c, c->status.active);
+               terminate_connection(c, c->edge);
                return;
        }
 }
@@ -418,7 +416,7 @@ int reload_configuration(void) {
                struct stat s;
                if(stat(fname, &s) || s.st_mtime > last_config_check) {
                        logger(DEBUG_CONNECTIONS, LOG_INFO, "Host config file of %s has been changed", c->name);
-                       terminate_connection(c, c->status.active);
+                       terminate_connection(c, c->edge);
                }
                free(fname);
        }