X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fautoconnect.c;h=d771078af7a0a19e5c575697b25ba68f435800b1;hb=01dc7836703ba3aa113f3d0102f13ba73319e50b;hp=1609363372b6be7bd8138ad9d0b595797426d69d;hpb=6debc6c79ba385d35f646e0958f84ace5b8f4b4d;p=tinc diff --git a/src/autoconnect.c b/src/autoconnect.c index 16093633..d771078a 100644 --- a/src/autoconnect.c +++ b/src/autoconnect.c @@ -1,6 +1,6 @@ /* autoconnect.c -- automatic connection establishment - Copyright (C) 2017 Guus Sliepen + Copyright (C) 2017-2022 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,13 +19,14 @@ #include "system.h" +#include "autoconnect.h" #include "connection.h" #include "crypto.h" #include "logger.h" #include "node.h" #include "xalloc.h" -static void make_new_connection() { +static void make_new_connection(void) { /* Select a random node we haven't connected to yet. */ uint32_t count = 0; @@ -48,7 +49,8 @@ static void make_new_connection() { continue; } - if(r--) { + if(r) { + --r; continue; } @@ -73,7 +75,7 @@ static void make_new_connection() { } } -static void connect_to_unreachable() { +static void connect_to_unreachable(void) { /* Select a random known node. The rationale is that if there are many * reachable nodes, and only a few unreachable nodes, we don't want all * reachable nodes to try to connect to the unreachable ones at the @@ -110,7 +112,7 @@ static void connect_to_unreachable() { } } -static void drop_superfluous_outgoing_connection() { +static void drop_superfluous_outgoing_connection(void) { /* Choose a random outgoing connection to a node that has at least one other connection. */ uint32_t count = 0; @@ -145,7 +147,7 @@ static void drop_superfluous_outgoing_connection() { } } -static void drop_superfluous_pending_connections() { +static void drop_superfluous_pending_connections(void) { for list_each(outgoing_t, o, &outgoing_list) { /* Only look for connections that are waiting to be retried later. */ bool found = false; @@ -166,7 +168,7 @@ static void drop_superfluous_pending_connections() { } } -void do_autoconnect() { +void do_autoconnect(void) { /* Count number of active connections. */ uint32_t nc = 0;