summaryrefslogtreecommitdiffstats
path: root/ctdb
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2014-01-22 17:01:19 +1100
committerAmitay Isaacs <amitay@samba.org>2014-03-23 06:20:43 +0100
commit20c719677a28afa1d1b912b9fadbf384e9e65de7 (patch)
treee7fc8936aea4975ff1b7700913cb12682e7b0fb5 /ctdb
parent9b907536fb657fa15c02858caf0ffff633ecd478 (diff)
downloadsamba-20c719677a28afa1d1b912b9fadbf384e9e65de7.tar.gz
samba-20c719677a28afa1d1b912b9fadbf384e9e65de7.tar.xz
samba-20c719677a28afa1d1b912b9fadbf384e9e65de7.zip
ctdb/daemon: Optimise deletion of IPs
Previous commits maintained the ordering between ctdb_remove_orphaned_ifaces() and ctdb_vnn_unassign_iface(). This meant that ctdb_remove_orphaned_ifaces() needed to steal the orphaned interfaces and they would be freed later. Unassign the interface first and things get simpler. ctdb_remove_orphaned_ifaces() is now self-contained. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com> Autobuild-User(master): Amitay Isaacs <amitay@samba.org> Autobuild-Date(master): Sun Mar 23 06:20:43 CET 2014 on sn-devel-104
Diffstat (limited to 'ctdb')
-rw-r--r--ctdb/server/ctdb_takeover.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c
index 9c699be4fff..bbb02263687 100644
--- a/ctdb/server/ctdb_takeover.c
+++ b/ctdb/server/ctdb_takeover.c
@@ -118,19 +118,20 @@ static bool vnn_has_interface_with_name(struct ctdb_vnn *vnn,
* causes problems... :-)
*/
static void ctdb_remove_orphaned_ifaces(struct ctdb_context *ctdb,
- struct ctdb_vnn *vnn,
- TALLOC_CTX *mem_ctx)
+ struct ctdb_vnn *vnn)
{
struct ctdb_iface *i;
/* For each interface, check if there's an IP using it. */
- for(i=ctdb->ifaces; i; i=i->next) {
+ i = ctdb->ifaces;
+ while (i != NULL) {
struct ctdb_vnn *tv;
bool found;
+ struct ctdb_iface *next = i->next;
/* Only consider interfaces named in the given VNN. */
if (!vnn_has_interface_with_name(vnn, i->name)) {
- continue;
+ goto next;
}
/* Is the "single IP" on this interface? */
@@ -138,7 +139,7 @@ static void ctdb_remove_orphaned_ifaces(struct ctdb_context *ctdb,
(ctdb->single_ip_vnn->ifaces[0] != NULL) &&
(strcmp(i->name, ctdb->single_ip_vnn->ifaces[0]) == 0)) {
/* Found, next interface please... */
- continue;
+ goto next;
}
/* Search for a vnn with this interface. */
found = false;
@@ -152,9 +153,11 @@ static void ctdb_remove_orphaned_ifaces(struct ctdb_context *ctdb,
if (!found) {
/* None of the VNNs are using this interface. */
DLIST_REMOVE(ctdb->ifaces, i);
- /* Caller will free mem_ctx when convenient. */
- talloc_steal(mem_ctx, i);
+ talloc_free(i);
}
+
+ next:
+ i = next;
}
}
@@ -871,13 +874,10 @@ static void release_kill_clients(struct ctdb_context *ctdb, ctdb_sock_addr *addr
static void do_delete_ip(struct ctdb_context *ctdb, struct ctdb_vnn *vnn)
{
- TALLOC_CTX *mem_ctx = talloc_new(ctdb);
-
DLIST_REMOVE(ctdb->vnn, vnn);
- ctdb_remove_orphaned_ifaces(ctdb, vnn, mem_ctx);
ctdb_vnn_unassign_iface(ctdb, vnn);
+ ctdb_remove_orphaned_ifaces(ctdb, vnn);
talloc_free(vnn);
- talloc_free(mem_ctx);
}
/*