From: Martin Schwenke Date: Tue, 22 Mar 2016 21:20:07 +0000 (+1100) Subject: ctdb-killtcp: Keep track of number of kill attempts and maximum allowed X-Git-Tag: tdb-1.3.9~31 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=402f3c0460f072c316bc8f0b28c2adf7164b513c;p=thirdparty%2Fsamba.git ctdb-killtcp: Keep track of number of kill attempts and maximum allowed Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- 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; }