From: Amitay Isaacs Date: Mon, 20 Nov 2017 04:17:15 +0000 (+1100) Subject: ctdb-takeover: Refactor code to send tickle lists for all public IPs X-Git-Tag: samba-4.6.12~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7d173bfcc555f186c7c1decc989b1fc60c1155bb;p=thirdparty%2Fsamba.git 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 (cherry picked from commit 2b253f6b1bc4e765f3fcb614a3b67b14084a625d) --- diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c index 513da63cd38..b75dfb07e90 100644 --- a/ctdb/server/ctdb_takeover.c +++ b/ctdb/server/ctdb_takeover.c @@ -1995,43 +1995,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);