]> git.meshlink.io Git - meshlink/blobdiff - src/net.c
Stop using global variable mesh in net_socket.[ch].
[meshlink] / src / net.c
index 12f2f33d7c48e921ced4558ef77b3e423dd5dee9..f543c207259c049d0886e75120304deecc405a69 100644 (file)
--- a/src/net.c
+++ b/src/net.c
@@ -105,7 +105,7 @@ void terminate_connection(connection_t *c, bool report) {
        /* Check if this was our outgoing connection */
 
        if(outgoing)
-               do_outgoing_connection(outgoing);
+               do_outgoing_connection(mesh, outgoing);
 
 #ifndef HAVE_MINGW
        /* Clean up dead proxy processes */
@@ -124,11 +124,11 @@ void terminate_connection(connection_t *c, bool report) {
 */
 static void timeout_handler(event_loop_t *loop, void *data) {
        for list_each(connection_t, c, mesh->connections) {
-               if(c->last_ping_time + mesh->pingtimeout <= now.tv_sec) {
+               if(c->last_ping_time + mesh->pingtimeout <= mesh->loop.now.tv_sec) {
                        if(c->status.active) {
                                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 + mesh->pinginterval <= now.tv_sec) {
+                                       logger(DEBUG_CONNECTIONS, LOG_INFO, "%s (%s) didn't respond to PING in %ld seconds", c->name, c->hostname, (long)mesh->loop.now.tv_sec - c->last_ping_time);
+                               } else if(c->last_ping_time + mesh->pinginterval <= mesh->loop.now.tv_sec) {
                                        send_ping(c);
                                        continue;
                                } else {
@@ -208,7 +208,7 @@ static void periodic_handler(event_loop_t *loop, void *data) {
                                        outgoing_t *outgoing = xzalloc(sizeof *outgoing);
                                        outgoing->name = xstrdup(n->name);
                                        list_insert_tail(mesh->outgoings, outgoing);
-                                       setup_outgoing_connection(outgoing);
+                                       setup_outgoing_connection(mesh, outgoing);
                                }
                                break;
                        }
@@ -276,7 +276,7 @@ int reload_configuration(void) {
        exit_configuration(&mesh->config);
        init_configuration(&mesh->config);
 
-       if(!read_server_config()) {
+       if(!read_server_config(mesh)) {
                logger(DEBUG_ALWAYS, LOG_ERR, "Unable to reread configuration file.");
                return EINVAL;
        }
@@ -286,11 +286,11 @@ int reload_configuration(void) {
 
        /* Parse some options that are allowed to be changed while tinc is running */
 
-       setup_myself_reloadable();
+       setup_myself_reloadable(mesh);
 
        /* Try to make outgoing connections */
 
-       try_outgoing_connections();
+       try_outgoing_connections(mesh);
 
        /* Close connections to hosts that have a changed or deleted host config file */
 
@@ -303,7 +303,7 @@ int reload_configuration(void) {
                }
        }
 
-       mesh->last_config_check = now.tv_sec;
+       mesh->last_config_check = mesh->loop.now.tv_sec;
 
        return 0;
 }