Merge branch 'master' into 1.1
[tinc] / src / graph.c
index 4e060b7..5a0aab0 100644 (file)
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
 
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-    $Id$
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
 
 /* We need to generate two trees from the graph:
@@ -57,6 +55,7 @@
 #include "process.h"
 #include "subnet.h"
 #include "utils.h"
+#include "xalloc.h"
 
 /* Implementation of Kruskal's algorithm.
    Running time: O(E)
@@ -69,8 +68,6 @@ void mst_kruskal(void) {
        node_t *n;
        connection_t *c;
 
-       cp();
-       
        /* Clear MST status on connections */
 
        for(node = connection_tree->head; node; node = node->next) {
@@ -122,8 +119,6 @@ void sssp_dijkstra(void) {
        list_node_t *lnode, *nnode;
        bool indirect;
 
-       cp();
-
        todo_list = list_alloc(NULL);
 
        ifdebug(SCARY_THINGS) logger(LOG_DEBUG, "Running Dijkstra's algorithm:");
@@ -248,8 +243,6 @@ void sssp_bfs(void) {
        list_node_t *from, *todonext;
        bool indirect;
 
-       cp();
-
        todo_list = list_alloc(NULL);
 
        /* Clear visited status on nodes */
@@ -343,10 +336,10 @@ void check_reachability() {
                        n->status.reachable = !n->status.reachable;
 
                        if(n->status.reachable) {
-                               ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Node %s (%s) became reachable"),
+                               ifdebug(TRAFFIC) logger(LOG_DEBUG, "Node %s (%s) became reachable",
                                           n->name, n->hostname);
                        } else {
-                               ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Node %s (%s) became unreachable"),
+                               ifdebug(TRAFFIC) logger(LOG_DEBUG, "Node %s (%s) became unreachable",
                                           n->name, n->hostname);
                        }
 
@@ -359,18 +352,20 @@ void check_reachability() {
                        n->minmtu = 0;
                        n->mtuprobes = 0;
 
-                       asprintf(&envp[0], "NETNAME=%s", netname ? : "");
-                       asprintf(&envp[1], "DEVICE=%s", device ? : "");
-                       asprintf(&envp[2], "INTERFACE=%s", iface ? : "");
-                       asprintf(&envp[3], "NODE=%s", n->name);
+                       event_del(&n->mtuevent);
+
+                       xasprintf(&envp[0], "NETNAME=%s", netname ? : "");
+                       xasprintf(&envp[1], "DEVICE=%s", device ? : "");
+                       xasprintf(&envp[2], "INTERFACE=%s", iface ? : "");
+                       xasprintf(&envp[3], "NODE=%s", n->name);
                        sockaddr2str(&n->address, &address, &port);
-                       asprintf(&envp[4], "REMOTEADDRESS=%s", address);
-                       asprintf(&envp[5], "REMOTEPORT=%s", port);
+                       xasprintf(&envp[4], "REMOTEADDRESS=%s", address);
+                       xasprintf(&envp[5], "REMOTEPORT=%s", port);
                        envp[6] = NULL;
 
                        execute_script(n->status.reachable ? "host-up" : "host-down", envp);
 
-                       asprintf(&name,
+                       xasprintf(&name,
                                         n->status.reachable ? "hosts/%s-up" : "hosts/%s-down",
                                         n->name);
                        execute_script(name, envp);