From 65445d55038bb3b6ded667fdad34d4e69bc75fe1 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Thu, 11 Aug 2016 14:07:44 +1000 Subject: [PATCH] ctdb-daemon: Use release_ip_post() when releasing all IP addresses This has the advantage of using common code. Also, if there was previously a failed attempt to release the IP address as part of a delete, then this will finish processing the delete. Extra care needs to be taken when a VNN is actually deleted. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12158 Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs (cherry picked from commit d2a91394f55a2e0152bf470dac2608618db13b1f) --- ctdb/server/ctdb_takeover.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c index 1687bb49520..3871799c773 100644 --- a/ctdb/server/ctdb_takeover.c +++ b/ctdb/server/ctdb_takeover.c @@ -2121,15 +2121,17 @@ void ctdb_takeover_client_destructor_hook(struct ctdb_client *client) void ctdb_release_all_ips(struct ctdb_context *ctdb) { - struct ctdb_vnn *vnn; + struct ctdb_vnn *vnn, *next; int count = 0; - TDB_DATA data; if (ctdb->tunable.disable_ip_failover == 1) { return; } - for (vnn=ctdb->vnn;vnn;vnn=vnn->next) { + for (vnn = ctdb->vnn; vnn != NULL; vnn = next) { + /* vnn can be freed below in release_ip_post() */ + next = vnn->next; + if (!ctdb_sys_have_ip(&vnn->public_address)) { ctdb_vnn_unassign_iface(ctdb, vnn); continue; @@ -2171,13 +2173,10 @@ void ctdb_release_all_ips(struct ctdb_context *ctdb) continue; } - data.dptr = (uint8_t *)ctdb_addr_to_str(&vnn->public_address); - data.dsize = strlen((char *)data.dptr) + 1; - ctdb_daemon_send_message(ctdb, ctdb->pnn, - CTDB_SRVID_RELEASE_IP, data); - - ctdb_vnn_unassign_iface(ctdb, vnn); - vnn->update_in_flight = false; + vnn = release_ip_post(ctdb, vnn, &vnn->public_address); + if (vnn != NULL) { + vnn->update_in_flight = false; + } count++; } -- 2.11.4.GIT