From 402f3c0460f072c316bc8f0b28c2adf7164b513c Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Wed, 23 Mar 2016 08:20:07 +1100 Subject: [PATCH] ctdb-killtcp: Keep track of number of kill attempts and maximum allowed Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- ctdb/tools/ctdb_killtcp.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ctdb/tools/ctdb_killtcp.c b/ctdb/tools/ctdb_killtcp.c index 11028cc954c..b305b71efb4 100644 --- a/ctdb/tools/ctdb_killtcp.c +++ b/ctdb/tools/ctdb_killtcp.c @@ -41,6 +41,8 @@ struct ctdb_kill_tcp { trbt_tree_t *connections; void *private_data; void *destructor_data; + unsigned int attempts; + unsigned int max_attempts; }; static const char *prog; @@ -170,7 +172,7 @@ static int tickle_connection_traverse(void *param, void *data) struct ctdb_killtcp_con *con = talloc_get_type(data, struct ctdb_killtcp_con); /* have tried too many times, just give up */ - if (con->count >= 5) { + if (con->count >= con->killtcp->max_attempts) { /* can't delete in traverse: reparent to delete_cons */ talloc_steal(param, con); return 0; @@ -199,6 +201,8 @@ static void ctdb_tickle_sentenced_connections(struct tevent_context *ev, /* now we've finished traverse, it's safe to do deletion. */ talloc_free(delete_cons); + killtcp->attempts++; + /* If there are no more connections to kill we can remove the entire killtcp structure */ @@ -258,6 +262,10 @@ static int ctdb_killtcp(struct tevent_context *ev, killtcp->capture_fd = -1; killtcp->connections = trbt_create(killtcp, 0); + + killtcp->attempts = 0; + killtcp->max_attempts = 5; + *killtcp_arg = killtcp; } -- 2.47.3