]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-killtcp: Keep track of number of kill attempts and maximum allowed
authorMartin Schwenke <martin@meltin.net>
Tue, 22 Mar 2016 21:20:07 +0000 (08:20 +1100)
committerAmitay Isaacs <amitay@samba.org>
Fri, 1 Apr 2016 02:42:12 +0000 (04:42 +0200)
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tools/ctdb_killtcp.c

index 11028cc954cacaa1b470d05156d68b352e847bf7..b305b71efb4a96c2b35d14774126c05d9d5c0841 100644 (file)
@@ -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;
        }