]> git.ipfire.org Git - location/libloc.git/commitdiff
tree: Add network to the stack after we have tried again
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 6 Mar 2025 16:24:46 +0000 (16:24 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 6 Mar 2025 16:24:46 +0000 (16:24 +0000)
If we add it before, we will try to merge the network with itself which
is not necessary as it will never result in anything good.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/network-tree.c

index 70966251b597608ad50bbd4f9d05df520e4656a9..c2627e3b30985d545e4481d0de082a491ff71728 100644 (file)
@@ -396,11 +396,6 @@ static int loc_network_tree_merge_step(struct loc_network* network, void* data)
                        if (r)
                                goto ERROR;
 
-                       // Add the new network to the stack
-                       r = loc_network_list_push(ctx->networks, m);
-                       if (r)
-                               goto ERROR;
-
                        // Remove the previous network from the stack
                        r = loc_network_list_remove(ctx->networks, n);
                        if (r)
@@ -414,6 +409,11 @@ static int loc_network_tree_merge_step(struct loc_network* network, void* data)
                        if (r)
                                goto ERROR;
 
+                       // Add the new network to the stack
+                       r = loc_network_list_push(ctx->networks, m);
+                       if (r)
+                               goto ERROR;
+
                        loc_network_unref(m);
                        m = NULL;