From 2b253f6b1bc4e765f3fcb614a3b67b14084a625d Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Mon, 20 Nov 2017 15:17:15 +1100 Subject: [PATCH] ctdb-takeover: Refactor code to send tickle lists for all public IPs BUG: https://bugzilla.samba.org/show_bug.cgi?id=13154 Signed-off-by: Amitay Isaacs Reviewed-by: Martin Schwenke --- ctdb/server/ctdb_takeover.c | 44 +++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c index 5e8aabfe80e..22dd878818d 100644 --- a/ctdb/server/ctdb_takeover.c +++ b/ctdb/server/ctdb_takeover.c @@ -1983,43 +1983,53 @@ static int ctdb_send_set_tcp_tickles_for_ip(struct ctdb_context *ctdb, return ret; } - -/* - perform tickle updates if required - */ -static void ctdb_update_tcp_tickles(struct tevent_context *ev, - struct tevent_timer *te, - struct timeval t, void *private_data) +static void ctdb_send_set_tcp_tickles_for_all(struct ctdb_context *ctdb, + bool force) { - struct ctdb_context *ctdb = talloc_get_type(private_data, struct ctdb_context); - int ret; struct ctdb_vnn *vnn; + int ret; - for (vnn=ctdb->vnn;vnn;vnn=vnn->next) { - /* we only send out updates for public addresses that + for (vnn = ctdb->vnn; vnn != NULL; vnn = vnn->next) { + /* we only send out updates for public addresses that we have taken over */ if (ctdb->pnn != vnn->pnn) { continue; } + /* We only send out the updates if we need to */ - if (!vnn->tcp_update_needed) { + if (!force && !vnn->tcp_update_needed) { continue; } + ret = ctdb_send_set_tcp_tickles_for_ip(ctdb, &vnn->public_address, vnn->tcp_array); if (ret != 0) { - DEBUG(DEBUG_ERR,("Failed to send the tickle update for public address %s\n", - ctdb_addr_to_str(&vnn->public_address))); + D_ERR("Failed to send the tickle update for ip %s\n", + ctdb_addr_to_str(&vnn->public_address)); + vnn->tcp_update_needed = true; } else { - DEBUG(DEBUG_INFO, - ("Sent tickle update for public address %s\n", - ctdb_addr_to_str(&vnn->public_address))); + D_INFO("Sent tickle update for ip %s\n", + ctdb_addr_to_str(&vnn->public_address)); vnn->tcp_update_needed = false; } } +} + +/* + perform tickle updates if required + */ +static void ctdb_update_tcp_tickles(struct tevent_context *ev, + struct tevent_timer *te, + struct timeval t, void *private_data) +{ + struct ctdb_context *ctdb = talloc_get_type( + private_data, struct ctdb_context); + + ctdb_send_set_tcp_tickles_for_all(ctdb, false); + tevent_add_timer(ctdb->ev, ctdb->tickle_update_context, timeval_current_ofs(ctdb->tunable.tickle_update_interval, 0), ctdb_update_tcp_tickles, ctdb); -- 2.34.1